Static Class Or Utility Class C# with Example
using System; namespace CSharpClass { // Static classes can only contain static members! static class TimeUtilClass { public static void PrintTime() { Console.WriteLine(DateTime.Now.ToShortTimeString()); } public static void PrintDate() { Console.WriteLine(DateTime.Today.ToShortDateString()); } } class UsingStudent { static void Main(string[] args) { Console.Write("Today's Date: " ); TimeUtilClass.PrintDate(); Console.Write("Current Time: " ); TimeUtilClass.PrintTime(); // Compiler error! Can't create static classes! // TimeUtilClass u = new TimeUtilClass (); } } }