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;
		}
	}

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.