Use property in a struct : Properties : Struct C# Examples


C# Examples » Struct » Properties »

 

Use property in a struct









    
using  System;

public  struct  Square
{
      public  int  Width
      {
            get
            {
                  return  width;
            }

            set
            {
                  width  =  value;
            }
      }

      public  int  Height
      {
            get
            {
                  return  height;
            }

            set
            {
                  height  =  value;
            }
      }
      
      private  int  width;
      private  int  height;
}

public  class  MainClass
{
      static  void  Main()
      {
            Square  sq  =  new  Square();
            sq.Width  =  1;
            sq.Height  =  1;
      }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Properties