Structure Members - CSharp Custom Type

CSharp examples for Custom Type:struct

Introduction

The following is a structure for storing a point:

struct Point
{
          public int x;
          public int y;
}

A structure with two data members

Demo Code

struct point
{
   public int x;
   public int y;
}
class MainClass//from  w  ww. j a v  a2s  .  c  om
{
   public static void Main()
   {
      point starting = new point();
      point ending = new point();
      starting.x = 1;
      starting.y = 4;
      ending.x = 10;
      ending.y = 11;
      System.Console.WriteLine("Point 1: ({0},{1})", starting.x, starting.y);
      System.Console.WriteLine("Point 2: ({0},{1})", ending.x, ending.y);
   }
}

Result


Related Tutorials