Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global variable in a static method

This seems basic but Im finding this quite trivial. Simply how would you recommend setting a global variable with a static class (i.e. console-application)?

To give you a little more background the main method is calling some custom eventhandlers that I hope to get / set the variables.

Any ideas or suggestions you have is appreciated.

like image 540
Leroy Jenkins Avatar asked Feb 17 '10 03:02

Leroy Jenkins


1 Answers

Simplest way is

public static Object MyGlobalVariable;

which creates a public static field. A little better is:

public static Object MyGlobalVariable { get; set; }

Which creates a public static property.

like image 117
Samuel Neff Avatar answered Oct 07 '22 17:10

Samuel Neff