Create class with public data members - CSharp Custom Type

CSharp examples for Custom Type:access level

Description

Create class with public data members

Demo Code

class point/*from ww  w  .  j  av  a2 s.  com*/
{
   public int x;
   public int y;
}
class line
{
   public point starting = new point();
   public point ending = new point();
}
class lineApp
{
   public static void Main()
   {
      line v = new line();
      v.starting.x = 1;
      v.starting.y = 4;
      v.ending.x = 10;
      v.ending.y = 11;
      System.Console.WriteLine("Point 1: ({0},{1})", v.starting.x, v.starting.y);
      System.Console.WriteLine("Point 2: ({0},{1})", v.ending.x, v.ending.y);
   }
}

Result


Related Tutorials