我上了课 Column
public class Column
{
public int Id { get; private set; }
public string Name { get; private set; }
public EPersonalCharacteristicType Type { get; private set; }
public Column MainColumn { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
而且我在另一个班级中有以下字段
Dictionary<Column, string> dictionary
Run Code Online (Sandbox Code Playgroud)
在执行过程中,我得到了一个奇怪的行为dictionary.当我输入
dictionary.ContainsKey(dictionary.Keys.ToList()[1])
Run Code Online (Sandbox Code Playgroud)
我有false.
地球上怎么样?
UPDATED
我的Column类有GetHashCode或Equals Functions.以下是它们的实现:
public bool Equals(Column other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return other.Id == Id && Equals(other.Name, Name) && Equals(other.Type, …Run Code Online (Sandbox Code Playgroud)