Variable declaration

Variable declaration is different, including access and type specification.

JavaScript: The type specification is not necessary.

public var playerLife = 1;       // a public var
int playerLife = 2;        // **private** access is default
public GameObject myObj;      // a type is specified (no value assigned)

C#: The type is always stated when declaring a variable.

var playerLife = 1;         // **public** access is default
private var playerLife = 2;      // a private var
var myObj : GameObject;       // a type is specified (no value assigned)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.47.218