[C#] "var" problem

Every time i use “var” i get this strange error:

Assets/NewBehaviourScript.cs(49,37):
error CS1525: Unexpected symbol :', expecting )‘, ,', ;’, [', or =’

Example of code I was using:

var texture : Texture;

In C# you never use

var texture;

only

var texture = something…

and only within methods, if this is a class attribute you have to specify type as:

public Texture texture;

if you use c# you dont use var for initializing a variable

here an example to how to do it

public float movingSpeed = 100;

hope it could help

var texture : Texture is not C#. That’s JavaScript.

You want:

Texture texture; // This is C#