Declare a struct : struct definition « struct « C# / CSharp Tutorial






using System;

struct Point
{
    public Point(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    public override string ToString()
    {
        return(String.Format("({0}, {1})", x, y));
    }
    
    public int x;
    public int y;
}

class MainClass
{
    public static void Main()
    {
        Point start = new Point(5, 5);
        Console.WriteLine("Start: {0}", start);
    }
}
Start: (5, 5)








6.2.struct definition
6.2.1.Declare the Rectangle struct
6.2.2.Declaration of a struct and use it
6.2.3.Declare a struct
6.2.4.Use enum data type in a struct
6.2.5.Composite Struct
6.2.6.Create A Struct Using Default Constructor
6.2.7.Defining struct