Declare a struct : Struct definition : Struct C# Examples


C# Examples » Struct » Struct definition »

 

Declare a struct









    
using  System;

struct  Point
{
        public  Point(int  x,  int  y)
        {
                this.x  =  x;
                this.y  =  y;
        }
        public  override  string  ToString()
        {
                return(String.Format("({0},  {1})",  x,  y));
        }
        
        public  int  x;
        public  int  y;
}

class  MainClass
{
        public  static  void  Main()
        {
                Point  start  =  new  Point(5,  5);
                Console.WriteLine("Start:  {0}",  start);
        }
}
    
   
  
   



Output

Start: (5, 5)


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Struct definition