CSharp examples for Custom Type:struct
Create A line structure which contains point structures
struct point { private int point_x; private int point_y; public int x {/*from ww w . ja va2 s . co m*/ get { return point_x; } set { point_x = value; } } public int y { get { return point_y; } set { point_y = value; } } } struct line { private point line_starting; private point line_ending; public point starting { get { return line_starting; } set { line_starting = value; } } public point ending { get { return line_ending; } set { line_ending = value; } } } class lineApp { public static void Main() { line myLine = new line(); point tmp_point = new point(); tmp_point.x = 1; tmp_point.y = 4; myLine.starting = tmp_point; tmp_point.x = 10; tmp_point.y = 11; myLine.ending = tmp_point; 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); } }