Newbie question about variables in C#

Hello, My game is almost done but in the last minute I saw some problems with the pause menu, I was using a free pause menu I got from the asset store but I decided to make my own pause menu, So I finished it and debugged it and then I got this error

Assets/Pause Menu/pausemenu.cs(5,17): error CS0825: The contextual keyword `var’ may only appear within a local variable declaration

I’ve tried switching my variable to a boolean and an int but it just brought more problems when I did that
Here’s the code I wrote

using UnityEngine;
using System.Collections;

public class pausemenu : MonoBehaviour {
	private var Pauseenabled;
	
	void OnGUI(){
		if (Pauseenabled == true){
			if (GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 - 50,250,50),"Main Menu")){
				Application.LoadLevel("Main Menu");
			}
	}
}

	// Use this for initialization
	void Start(){
		Pauseenabled = false;
		Time.timescale = 1.0F;
		Screen.showcursor = false;
	
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown("escape")){
			if (Pauseenabled == true){
				Pauseenabled = false;
				Time.timescale = 1.0F;
				Screen.showcursor = false;
			}
		}
			
		else if (Pauseenabled == false){
				Pauseenabled = true;
				Time.timescale = 0.0F;
				Screen.showcursor = true;
	
	}
  }
}

You need to specify a type, bool is what you need.

private bool Pauseenabled = false;
privat int myint = 1;

declare it as bool it will be fine

var will work only on js

c# is more like c++, the syntax of declaration changes completely.

Also note that var works in C# inside methods, just not in class field declarations.

I changed it to a bool but theres this whole bunch off errors like
Assets/Pause Menu/pausemenu.cs(9,40): error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected
Assets/Pause Menu/pausemenu.cs(9,33): error CS1502: The best overloaded method match for UnityEngine.GUI.Button(UnityEngine.Rect, string)' has some invalid arguments Assets/Pause Menu/pausemenu.cs(9,33): error CS1503: Argument #1’ cannot convert object' expression to type UnityEngine.Rect’
Assets/Pause Menu/pausemenu.cs(18,22): error CS0117: UnityEngine.Time' does not contain a definition for timescale’
Assets/Pause Menu/pausemenu.cs(19,24): error CS0117: UnityEngine.Screen' does not contain a definition for showcursor’

my current script

public class pausemenu : MonoBehaviour {
	bool Pauseenabled;
	
	void OnGUI(){
		if (Pauseenabled == true){
			if (GUI.Button(Rect(300,300,100,80),"Main Menu")){
				Application.LoadLevel("Main Menu");
			}
	}
}

	// Use this for initialization
	void Start(){
		Pauseenabled = false;
		Time.timescale = 1.0F;
		Screen.showcursor = false;
	
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown("escape")){
			if (Pauseenabled == true){
				Pauseenabled = false;
				Time.timescale = 1.0F;
				Screen.showcursor = false;
			}
		}
			
		else if (Pauseenabled == false){
				Pauseenabled = true;
				Time.timescale = 0.0F;
				Screen.showcursor = true;
	
	}
  }
}

change

Screen.showcursor

to

Screen.showCursor

also change

Time.timescale

to

Time.timeScale

Also where you have defined your Button you didn’t put a new before the Rect. put one in and all should one sweetly

this leaves yur code as

    public class pausemenu : MonoBehaviour
    {
        bool Pauseenabled;

        void OnGUI()
        {
            if (Pauseenabled == true)
            {
                if (GUI.Button( new Rect(300, 300, 100, 80), "Main Menu"))
                {
                    Application.LoadLevel("Main Menu");
                }
            }
        }

        // Use this for initialization
        void Start()
        {
            Pauseenabled = false;
            Time.timeScale = 1.0F;
            Screen.showCursor = false;

        }

        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown("escape"))
            {
                if (Pauseenabled == true)
                {
                    Pauseenabled = false;
                    Time.timeScale = 1.0F;
                    Screen.showCursor = false;
                }
            }

            else if (Pauseenabled == false)
            {
                Pauseenabled = true;
                Time.timeScale = 0.0F;
                Screen.showCursor = true;

            }
        }
    }