字典<keyvaluepair <t,e =“”>,V&gt;同时访问KeyValuePair

时间:2018-02-07 15:27:08

标签: c#

我使用 KeyValuePair 类型来存储行/列数据。我需要实现AddRow / AddColumn

public static Dictionary<KeyValuePair<T, E>, V> list = new Dictionary<KeyValuePair<T, E>, V>();
public KeyValuePair<T, E> val;
public void AddRow(T row)
{
       val = new KeyValuePair<T, E>(row, default(E));
       list.Add(val, default(V));
}
public void AddColumn(E column)
{
       val = new KeyValuePair<T, E>(default(T), column);
       list.Add(val, default(V));
}

在我的实现中,创建了两个KeyValuePair对象,因此我无法为Key / Value分配值,因为它们是可读的,只读。如何最好地解决我的问题或创建单独的类来存储行/列,然后是表的公共类?

0 个答案:

没有答案