In C#, suppose you have an object (say, myObject
) that is an instance of class MyClass
.
Using myObject
only, how would you access a static member of MyClass
?
class MyClass
{
public static int i = 123 ;
}
class MainClass
{
public static void Main()
{
MyClass myObject = new MyClass() ;
myObject.GetType().i = 456 ; // something like this is desired,
// but erroneous
}
}