C
C#3y ago
Iceman228

Set property based on another

public class XmlTabColumnDefinition
{
[XmlIgnore] public string KeyValue { get; set; };
[XmlElement("KeyValue")] public XmlKeyValue XmlKeyValue { get; set; }
}
public class XmlKeyValue
{
[XmlAttribute("ColumnName")] public string ColumnName { get; set; };
}
public class XmlTabColumnDefinition
{
[XmlIgnore] public string KeyValue { get; set; };
[XmlElement("KeyValue")] public XmlKeyValue XmlKeyValue { get; set; }
}
public class XmlKeyValue
{
[XmlAttribute("ColumnName")] public string ColumnName { get; set; };
}
How can I set ColumnName based on KeyValue? Meaning when I change KeyValue during runtime, ColumnName gets the same value and the other way around.
5 Replies
Angius
Angius3y ago
Use the setters
Iceman228
Iceman228OP3y ago
Yes but idk how.
Angius
Angius3y ago
Just write the code you need in there You might need a backing field too
ero
ero3y ago
Isn't the other prop technically the backing field then
Iceman228
Iceman228OP3y ago
I just really have no idea how to write it.
Want results from more Discord servers?
Add your server