A static member of the class is a property, procedure, or field that is shared by all instances of a class.

To define a static member:

static class SampleClass  
{
public static string SampleString = "Sample String";
}


Console.WriteLine(SampleClass.SampleString);

Static classes in C# have static members only and cannot be instantiated. Static members also cannot access non-static properties, fields or methods

Last modified: March 20, 2019

Author

Comments

Write a Reply or Comment