struct can use automatic property implementation - CSharp Custom Type

CSharp examples for Custom Type:struct

Description

struct can use automatic property implementation

Demo Code

using System;//from  www.  j  a v a 2s . c  o m
class Program
{
   static void Main(string[] args)
   {
      X x = new X { A = 1 };  // Init just the instance member of X.
      X.B = 2;                // Init the static member.
      Console.WriteLine("X.A = {0}\nX.B = {1}", x.A, X.B);
   }
   public struct X
   {
      public int A { get; set; }
      public static double B { get; set; }
   }
}

Result


Related Tutorials