我在 C# 中有两个类似的类
public class Property
{
public string version;
public string CCodeName { get; set; }
public string CDoc { get; set; }
public string ShortName { get; set; }
}
public class PropertyFieldsInExcel
{
public string ShortNames { get; set; }
public string CNames { get; set; }
public string CDoc { get; set; }
public string Version { get; set; }
}
在此之后,我创建了两个列表。
static List<PropertyFieldsInExcel> listA = new List<PropertyFieldsInExcel>();
public List<Property> listB = new List<Property>();
现在,我想在这两个列表之间进行双向绑定。例如,每当listA
相应元素中的某些内容发生变化时,都listB
必须更新。
与 if 一样,listA[i].ShortName = "abc"
thenlistB[i].ShortName
也必须具有相同的值。
listA.Add()
应该触发listB.Add()
,反之亦然。
谢谢!