Declaration of a struct and use it : struct definition « struct « C# / CSharp Tutorial






using System;

public struct MyStruct
{
  public int MyInt;
  public long MyLong;
  public string MyString;
}

class MainClass
{
  static void Main(string[] args)
  {
    MyStruct TheStruct;

    TheStruct.MyInt = 0;
    TheStruct.MyLong = 0;
    TheStruct.MyString = "Hello World";
  }
}








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