I have seen that get/set properties can be used in two different ways:
Without any logic:
public string PublicString { get; set; }
With logic, passing the value to backing field.
private string backingString;
public string PublicString
{
Get
{
Return backingString;
}
Set
{
If (value != “”)
{
backingString = value;
}
}
}
Questions:
- if you want to perform logic, do you have a backing property or is it possible to do PublicString = value?
- if you want to return an error when you failed to set the field, what would be the best practice for doing this?
Thanks