Description
A member of a class that provides flexibility for exposing private fields.
Sample Property Declaration
//backing private field
private string prop;
public string ReadWriteProp {
get {
return prop;
}
set {
prop = value;
}
}
public string ReadOnlyProp {
get {
return prop;
}
}
public string WriteOnlyProp {
set {
prop = value;
}
}
Sample Auto-Implemented Property Declaration
A more concise property declaration especially if theres no additional logic required for the accessors.
public string ReadWriteProp {
get; set;
}
public string ReadOnlyProp {
get; private set;
}
public string WriteOnlyProp {
private get; set;
}
Recent Comments