Create a Static Class and calls its method and property - CSharp Custom Type

CSharp examples for Custom Type:static

Description

Create a Static Class and calls its method and property

Demo Code

using System;/*from w w w  .  j a  v a2 s .c o  m*/
public static class MyStaticClass
{
   public static string getMessage()
   {
      return "This is a static member";
   }
   public static string StaticProperty
   {
      get;
      set;
   }
}
class MainClass
{
   static void Main(string[] args)
   {
      Console.WriteLine(MyStaticClass.getMessage());
      // set and get the property
      MyStaticClass.StaticProperty = "this is the property value";
      Console.WriteLine(MyStaticClass.StaticProperty);
   }
}

Result


Related Tutorials