vendredi 28 juillet 2017

How to relate a property to its backing field C#

I have a property that has its own private member backing field. I want to be able to relate the name of the property with the name of the backing field.

public bool AddPostDateToReference
{
    get
    {
        if (moAddPostDateToReference.Value.ToUpper() == "Y" || moAddPostDateToReference.Value.ToUpper() == "T") { return true; }
        else { return false; }
    }
    set
    {
        if (value) { moAddPostDateToReference.Value = "Y"; }
        else { moAddPostDateToReference.Value = "N"; }
    }
}

When doing a Quick-watch in the Visual Studio debugger, I am able to view the property "AddPostDateToReference" and the private member variable "moAddPostDateToReference" but not the relation on how they are connected.





Aucun commentaire:

Enregistrer un commentaire