Real time example for Structure in C#

A struct type is a value type that can contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types.
Structs are also typically used in graphics/rendering systems. There are many benefits to making points/vectors structs.

public struct Money
{
    public string Currency { get; set; }
    public double Amount { get; set; }
}
public struct PhoneNumber
{
    public int Extension { get; set; }
    public int RegionCode { get; set; }
    //... etc.
}
public struct FullName
{
    public string FirstName { get; set; }
    public string MiddleName { get; set; }
    public string LastName { get; set; }
}

 For more understanding of structure view the following link
http://www.c-sharpcorner.com/UploadFile/rajeshvs/StructuresInCS11112005234341PM/StructuresInCS.aspx

No comments:

Post a Comment