Creating the IEnumerable> Objects with C#?

前端 未结 5 1470
野趣味
野趣味 2020-12-25 11:01

For testing purposes, I need to create an IEnumerable> object with the following sample key value pairs:



        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-25 12:05

    You can simply assign a Dictionary to IEnumerable>

    IEnumerable> kvp = new Dictionary();
    

    If that does not work you can try -

    IDictionary dictionary = new Dictionary();
                IEnumerable> kvp = dictionary.Select((pair) => pair);
    

提交回复
热议问题