using System;
public class Program
{
public static void Main()
// Notice there is no implicitly defined instance of MyStaticClass!
Console.WriteLine("The result of MyStaticClass: {0}", MyStaticClass.Sum(2,2));
// --- Uncomment the line below and inspect the error
// --- You cannot create an instance of a static class
//MyStaticClass myClass = new MyStaticClass();
}
// MyStaticClass - declared with the 'static' keyword
public static class MyStaticClass
// --- static classes cannot have constructors
//public MyStaticClass()
//{
//}
// the method Sum must be static because the class is static
public static int Sum(int x, int y)
return x + y;