我正在使用字典包装类,我想使用键值对遍历它,如下所示
private void LoadVariables(LogDictionary dic)
{
foreach (var entry in dic)
{
_context.Variables[entry.Key] = entry.Value;
}
}
但是NotImplementedException
由于我没有实现该GetEnumerator()
方法,所以抛出了 a 。
这是我的包装类:
public class LogDictionary: IDictionary<String, object>
{
DynamicTableEntity _dte;
public LogDictionary(DynamicTableEntity dte)
{
_dte = dte;
}
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
{
throw new NotImplementedException();
}
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
{
throw new NotImplementedException();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
}