Problem with variables in c#

Hi.
I have some trouble with my c# code i get an error (expecting “;”.) when writing this.

using UnityEngine;
using System.Collections;
//using System.IO; 
public class txtprinter : MonoBehaviour {

	// Use this for initialization
	void Awake () {
		public string hello = "hello";
		//public string label;
	}
	
	// Update is called once per frame
	/*void Printing () {	
		TextWriter objWriter= new StreamWriter("hej.txt"); 
		//objWriter.WriteLine(label);
		objWriter.Flush(); 
		objWriter.Close(); 
		objWriter=null;
		print ("hej");
	}*/
}

In the Awake method, you have used the “public” modifier, but you can’t declare a local variable as public. If you want to add a property to the class then you have to declare it outside of any method body. If you want a local variable then just leave out the word “public”. If you are initialising the variable then write “varName = value;” rather than using a declaration.

OK thanks. That will help me a lot :smile: