格式化字典的键值

Ari*_*ule 1 c# dictionary

我想改变字典键值的格式.

就像是

Dictionary<string,string> dictcatalogue = new Dictionary<string,string>();

dictCatalogue = dictCatalogue.Select(t => t.Key.ToString().ToLower() + "-ns").ToDictionary();
Run Code Online (Sandbox Code Playgroud)

如何在不影响值的情况下更改字典的键

stu*_*rtd 5

您正在创建一个新词典的正确轨道:

dictcatalogue = dictcatalogue.ToDictionary
       (t => t.Key.ToString().ToLower() + "-ns", t => t.Value);
Run Code Online (Sandbox Code Playgroud)