Dictionary to List> where the Value in KeyValuePair is MyClass.ToString()

前端 未结 2 1396
轮回少年
轮回少年 2021-01-29 07:14
Dictionary dict = new Dictionary();

//where MyClass has an override for ToString()

Now how do I get a

2条回答
  •  花落未央
    2021-01-29 07:37

    Not tested/compiled, but something like that should work:

    dict.Select(kvp => new KeyValuePair(kvp.Key, kvp.Value.ToString())).ToList()
    

    if the syntax is not 100% spot on, I hope you got the idea.

提交回复
热议问题