C
C#2y 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
Angius2y ago
Use the setters
Iceman228
Iceman2282y ago
Yes but idk how.
Angius
Angius2y ago
Just write the code you need in there You might need a backing field too
ero
ero2y ago
Isn't the other prop technically the backing field then
Iceman228
Iceman2282y ago
I just really have no idea how to write it.