Create and use nested class - CSharp Custom Type

CSharp examples for Custom Type:Inner Type

Description

Create and use nested class

Demo Code

class line// w  w w  .  ja v  a2 s  .co m
{
   public class point
   {
      public int x;
      public int y;
   }
   public point starting = new point();
   public point ending = new point();
}
class lineApp
{
   public static void Main()
   {
      line myLine = new line();
      myLine.starting.x = 1;
      myLine.starting.y = 4;
      myLine.ending.x = 10;
      myLine.ending.y = 11;
      System.Console.WriteLine("Point 1: ({0},{1})", myLine.starting.x, myLine.starting.y);
      System.Console.WriteLine("Point 2: ({0},{1})", myLine.ending.x, myLine.ending.y);
   }
}

Result


Related Tutorials