CSharp examples for Custom Type:class
Using Classes as Data Members
class Point/* w w w . ja v a 2 s. c o m*/ { public int x; public int y; } class Line { public Point starting = new Point(); public Point ending = new Point(); public double len; } class MainClass { public static void Main() { Line myLine = new Line(); myLine.starting.x = 1; myLine.starting.y = 4; myLine.ending.x = 10; myLine.ending.y = 11; myLine.len = 100; 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); System.Console.WriteLine("Line Length: {0}", myLine.len); } }