I want to make a private member variable that is private even to the class that owns it, and can ONLY be accessed by its getters and setters. I know you can do this with auto-properties like
private int MyInt{ get; set;}
But I want to be able to modify the getter and setter so (for example) I could log how many times the field has been set (even by the owning class). Something like this
private int MyInt
{
get{ return hiddenValue; }
set{ hiddenValue = value; Console.Out.WriteLine("MyInt has been set");}
}
where "hiddenValue" is the member that is only accessible in the getter and setter. Why? because I'm a paranoid defensive programmer, I don't even trust myself :p.
Is this possible in C#? and if so, what is the syntax?
Thanks.