Static Class in C#
Such type of class which is marked by static keyword is known
as static class. All the members of static class must be static. We cannot declare
non-static members inside static class. We can access members of static class
by using Class name followed by access operator dot (.) followed by method name.
One thing important that we cannot instantiate static class means to say we
cannot create object of static class by using new keyword.
The following list provides the main feature of a static class
Contains only static members except for
Cannot create objects of static class.
Is sealed class.
Can not contain instance constructor or non
Creating static class
For creating static class we can use static keyword at the beginning
keyword to create a static class.
static class Program
Console.WriteLine("This is a static constructor.");
static string message;
static void disp()
public static void Main(string args)
= "Hello John..."; //Accessing static
This is a static constructor.