A static member belongs to a class and not to an object of the class
Static modifier can be used with fields, methods, properties, operators, events and constructors
A static member cannot be referenced through an instance
There is only one copy of a static member amongst all instances
Use of this is not allowed with static members
Code listing: Static Members
public class MyBaseC
{
public struct MyStruct
{
public static int x = 100;
}
}
To refer x:
MyBaseC.MyStruct.x
No comments:
Post a Comment