具体的には、ToDictionary() を使用したいと考えています。サンプルコードは次のとおりです。
public class Foo
{
public int a { get; set; }
public int b { get; set; }
public int c { get; set; }
}
public class Key
{
public int a { get; set; }
public int b { get; set; }
}
public class KeyEqualityComparer : IEqualityComparer<Key>
{
public int GetHashCode(Key k)
{
int hash = 17;
hash = hash * 23 + k.a.GetHashCode();
hash = hash * 23 + k.b.GetHashCode();
return hash;
}
public bool Equals(Key lhs, Key rhs)
{
return ((lhs.a == rhs.a) && (lhs.b == rhs.b));
}
}
static List<Foo> Data = new List<Foo>();
static Dictionary<Key, int> Data_Map = new Dictionary<Key, int>( new KeyEqualityComparer() );
static void Main(string[] args)
{
Data.Add(new Foo() { a = 0, b = 0, c = 99 });
Data.Add(new Foo() { a = 1, b = 0, c= 69 });
// Key: new Key() { a = ???, b = ??? }
// Value: c
Data_Map = Data.ToDictionary(???)
}