Convert Dictionary to Dictionary using LINQ?

前端 未结 3 1400
南方客
南方客 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:50

    var collectionNames = new Dictionary();
    Array.ForEach(Enum.GetNames(typeof(YOUR_TYPE)), name => 
    { 
      Int32 val = (Int32)Enum.Parse(typeof(YOUR_TYPE), name, true); 
      collectionNames[val] = name; 
    }); 
    

提交回复
热议问题