When you use Properties you have better control of what properties have.
private string name;
public string Name
{
get;
set;
}
is wrong it should be either
public string Name
{
get;
set;
}
or
private string name;
public string Name
{
get { return name;}
set { this.name = value;}
}
sometimes when you want variable to be set only inside class u can use
public string Name
{
get;
private set;
}
Properties combine aspects of both fields and methods. To the user of an object, a property appears to be a field, accessing the property requires exactly the same syntax. To the implementer of a class, a property is one or two code blocks, representing a get accessor and/or a set accessor. The code block for the get accessor is executed when the property is read; the code block for the set accessor is executed when the property is assigned a new value. A property without a set accessor is considered read-only. A property without a get accessor is considered write-only. A property with both accessors is read-write.
Source: http://msdn.microsoft.com/en-us/library/w86s7x04(v=vs.80).aspx