I think John Simmons has already put you on the right track, but I would like to ask you why you are having a log-in form be the parent of other forms: imho that's an unusual 'architectural' design.
Please give John S. full credit for his answer: what follows is just an elaboration of his suggestion:
Before C# 3, you'd typically write a static property in a static class like this:
public static class PropDemo
{
private static string _mString;
public static string MString
{
get { return _mString; }
set { _mString = value; }
}
}
With C# 3, the compiler will take care of automatically creating the 'backing field' (the variable '_mString' in the example above):
public static class PropDemo
{
public static string MString { set; get; }
}
And now, you can also have different levels of scope for the 'get and 'set functions of a property:
public static string MString { private set; get;}
Discussion: you
could make a public static variable, and use it in either a static class, or a dynamically allocated class; you
could also use a public static Property in a dynamically allocated class, but the principle of 'encapsulation' suggests it is best practice to go ahead and create a Property in a static class. Implementing 'validation' inside the 'setter' of a Property is a typical reason for use of a Property
rather than a 'global variable.'