You simply use a static class to provide global functionality. Static classes contain only static members and are not instantiated – essentially they are global functions and variables accessed via their class name (and namespace).

Issues:

There is no constructor.
Any class you want to include must be static also

An example:


	public static class MyGlobalClassName
	{
		public static string Name;
		public static int aNumber;
		public static List<string> MyList = new List<string>();

		public static void SomeMethodName()
		{
			Name = "starting name";
			aNumber = 5;
		}
	}

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.