Convert Dictionary to Dictionary using LINQ?

前端 未结 3 1406
南方客
南方客 2021-02-07 07:56

I\'m trying to find a LINQ oneliner that takes a Dictionary and returns a Dictionary....it might not be possible, but would be nice.

3条回答
  •  一个人的身影
    2021-02-07 08:35

    var result = dict.ToDictionary(kvp => kvp.Key,
                   kvp => (SomeEnum)Enum.ToObject(typeof(SomeEnum), kvp.Value));
    

提交回复
热议问题