如何传递方法
IEnumerable<KeyValuePair<string, IEnumerable<string>>>
我正在使用的方法需要将此作为参数,但我一生都无法弄清楚它应该是什么。我已经尝试过
Dictionary<string, List<string>>
并且 Visual Studio 希望将其转换为上面的内容,但在执行时会抛出错误。
蒂亚!已经晚了
您有一个带有此标头的方法:
void SomeMethod(IEnumerable<KeyValuePair<string, IEnumerable<string>>> input)
您拥有
Dictionary<string, List<string>> data
形式的源数据。
你这样称呼它:
SomeMethod(data.Select(x => new KeyValuePair<string, IEnumerable<string>>(x.Key, x.Value)));