Possible Duplicate:
C# / .NET : when structures are better than classes?
Given the following type
class Person
{
public int Id{get;}
public Name Name{get;set;}
public Address Address{get;set;}
}
public struct Name
{
public string First{get;set;}
public string Middle{get;set;}
public string Last{get;set;}
}
public class Address
{
public string Line1{get;set;}
public string Line2{get;set;}
public string City{get;set;}
public string StateCode{get;set;}
public string PostalCode{get;set;}
}
What will you use (class
or struct
) for the simple types Name and Address. What are the advantages of structs
over classes in C#?