C# Dictionary(字典) 替换Key(键值)的值方法


    var dict =new Dictionary<string,string>();
    dict.Add("abc","1");    
    dict.Add("abcd","2");   
    dict.Add("abcf","3");
    
    //将键值为"abc"的键改为"abce"
    dict = dict.ToDictionary(k => k.Key == "abc" ? "abce" : k.Key, k => k.Value);

    //暂时没想到更好的方法,欢迎大神们补充

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM