1st
string _myProperty { get; set; }
This is called an Auto Property in the .NET world. It's just syntactic sugar for #2.
2nd
string _myProperty;
public string myProperty
{
get { return _myProperty; }
set { _myProperty = value; }
}
This is the usual way to do it, which is required if you need to do any validation or extra code in your property. For example, in WPF if you need to fire a Property Changed Event. If you don't, just use the auto property, it's pretty much standard.
3
string _myProperty;
public string getMyProperty()
{
return this._myProperty;
}
public string setMyProperty(string value)
{
this._myProperty = value;
}
The this
keyword here is redundant. Not needed at all. These are just Methods that get and set as opposed to properties, like the Java way of doing things.