Composite Struct : struct definition « struct « C# / CSharp Tutorial






struct StructWithNoMembers
{
}
   
struct StructWithMembers
{
    short s;
    int i;
    long l;
    bool b;
}
   
struct CompositeStruct
{
    StructWithNoMembers a;
    StructWithMembers b;
    StructWithNoMembers c;
}
   
class SizeofCustomTypesApp
{
    unsafe public static void Main(string[] args) 
    {
        Console.WriteLine("sizeof StructWithNoMembers structure = {0}", sizeof(StructWithNoMembers));
        Console.WriteLine("sizeof StructWithMembers structure = {0}",sizeof(StructWithMembers));
        Console.WriteLine("sizeof CompositeStruct structure = {0}", sizeof(CompositeStruct));
    }
}








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