【发布时间】:2018-01-06 20:33:09
【问题描述】:
colDiffUpdated 和 colDiffTarget 有不同的值,如何将两个列表的差异添加到 colTypes?
假设每个列表都有不同的值。
public List<columnTypes> colType = new List<columnTypes>();
public List<coldiffTypes> colDiffUpdated = new List<coldiffTypes>();
public List<coldiffTypesTarget> colDiffTarget = new List<coldiffTypesTarget>();
这是我存储值的类
public class columnTypes
{
public string tblName { get; set; }
public string colName { get; set; }
public int maxLength { get; set; }
public string maxLengthStr { get; set; }
public bool isUnique { get; set; }
public bool isKey { get; set; }
public System.Type dataType { get; set; }
public bool isNullable { get; set; }
public bool isAutoIncrement { get; set; }
public string dataTypeName { get; set; }
public int numericPrecision { get; set; }
public int numericScale { get; set; }
}
public class coldiffTypes
{
public string tblName { get; set; }
public string colName { get; set; }
public int maxLength { get; set; }
public string maxLengthStr { get; set; }
public bool isUnique { get; set; }
public bool isKey { get; set; }
public System.Type dataType { get; set; }
public bool isNullable { get; set; }
public bool isAutoIncrement { get; set; }
public string dataTypeName { get; set; }
public int numericPrecision { get; set; }
public int numericScale { get; set; }
}
public class coldiffTypesTarget
{
public string tblName { get; set; }
public string colName { get; set; }
public int maxLength { get; set; }
public string maxLengthStr { get; set; }
public bool isUnique { get; set; }
public bool isKey { get; set; }
public System.Type dataType { get; set; }
public bool isNullable { get; set; }
public bool isAutoIncrement { get; set; }
public string dataTypeName { get; set; }
public int numericPrecision { get; set; }
public int numericScale { get; set; }
}
【问题讨论】:
-
我错了,还是这三个类完全一样?为什么不对所有三个列表使用一个类?
-
这些类是否以某种方式生成?它们是否可以从一个基类派生或至少实现相同的接口?
-
这里不仅价值不同.. 整个合同也不同。
-
我明白了。我现在明白了.. 假设我们有一个 1 类忽略 coliffTypes 和 coldiffTypesTarget 。因为他们有相同的对象,我可以比较 public List
colDiffUpdated = new List ();公共列表 colDiffTarget = new List ();如果我使用 except 或 intersect 它返回 null ..
标签: c# compare listobject