I am a little confused about how much I SHOULD do with properties. I have heard that properties should always represent a logical property of the class. Get and Set should almost never throw exceptions with the exception of ArgumentOutOfRange. Is that true? Is the following example totally wrong?
public bool DeviceRegistered
{
get{ return _Registered;}
set
{
if(value)
{
RegisterDevice();
_Registered = true;
}
else
{
UnRegisterDevice();
_Registered = false;
}
}
}
Also, If a method in the same class wants to change the value of a property should it go through the set accessor of the property or just modify the private variable _Registered directly?
If you have any additional advice when using properties please include! Thanks