Converting a javascript to C#

Would anyone be so kind as to help me convert this script to c#?

var cols:int = 4;
var rows:int = 4;
var totalCards:int = cols*rows;
var matchesNeededToWin:int = totalCards * 0.5;
var matchesMade:int = 0;
var cardW:int = 100;
var cardH:int = 100;
var aCards:Array;
var aGrid:Array;
var aCardsFlipped:ArrayList;
var playerCanClick:boolean;
var playerHasWon:boolean = false;


function Start()
{
	playerCanClick = true;
	aCards = new Array();
	aGrid = new Array();
	aCardsFlipped = new ArrayList();
	for(i=0; i<rows; i++)
	{
	aGrid *= new Array();*
  • for(j=0; j<cols; j++)*
  • {*
    _ aGrid*[j] = new Card();_
    _
    }_
    _
    }_
    _
    }*_

function OnGUI ()
{
* GUILayout.BeginArea (Rect (0,0,Screen.width,Screen.height));*
* BuildGrid();*
* GUILayout.EndArea();*
* print(“building grid!”);*
}

function BuildGrid()
{
GUILayout.BeginVertical();
for(i=0; i<rows; i++)
{
GUILayout.BeginHorizontal();
for(j=0; j<cols; j++)
{
var card:Object = aGrid*[j];*
if(GUILayout.Button(Resources.Load(card.img),
GUILayout.Width(cardW)))
{
Debug.Log(card.img);
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}

class Card extends System.Object
{
* var isFaceUp:boolean = false;*
* var isMatched:boolean = false;*
* var img:String;*
function Card()
{
img = “robot”;
}
}

I will convert a few of them as they have similar syntax

int cols = 4;
int rows = 4;
int totalCards = cols*rows;
int matchesNeededToWin = totalCards * 0.5;
int matchesMade = 0;

public void Start()
{
    playerCanClick = true;
    aCards = new Array();
    aGrid = new Array();
    aCardsFlipped = new ArrayList();
    for(i=0; i<rows; i++)
    {
    aGrid *= new Array();*

for(j=0; j<cols; j++)
{
aGrid*[j] = new Card();*
}
}
}
I think this is right.

I won’t convert everything for you, but I’ll tell you how.

  • For everything that says var something:int=number, change that to int something=number, and the same applies to bools, floats, etc…
  • For all 'function’s, change it to void.
  • Don’t forget to encompass everything in a class (which I’m sure you know how to do)
  • Unfortunately, I’ve never tried having two classes in one script, so I don’t know how to change that part to C# .

Hope this helps.