0

I have a class with a bunch of properties. Now I am going to add or eliminate some attributes to these properties at run time but i don't know how exactly i should do it.

The Class

Class myClass
{
    //Other codes
    public string DetailedAccountTitle
    {
        get { return detailedAccountTitle; }
        set { detailedAccountTitle = value; }
    }
    //Other codes
} 

Inside the caller

if ((bool)e.Value)
{
    //Add the attribute
}
else
{
    //Eliminate it
}

Now as you can see I am controlling an event inside the caller and i hope it adds the attribute if it gets true and eliminate it if it does not.

Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34
Mahmood Shahrokni
  • 226
  • 1
  • 3
  • 12

1 Answers1

0

I hope I understand your question correctly when you want to use attribute value set value when needed and when don't simply set to empty or null

myClass myclass = new myClass();

if ((bool)e.Value)
{
    myclass.DetailedAccountTitle = "Set Value";
}
else
{
    myclass.DetailedAccountTitle = String.Empty;
}
Alston Antony
  • 179
  • 2
  • 13