记一个Dictionary更新数据操作的低级错误,以示警示
作者:互联网
Dictionary<int, AAA> kv = new Dictionary<int, AAA> { { 1, new AAA() { Val = "abc" } } }; if (kv.TryGetValue(1, out AAA val)) { val = new AAA() { Val = "efg" }; //这样是错误的 kv[1] = new AAA() { Val = "efg" }; //这样才是对的 }
标签:AAA,Val,Dictionary,低级,val,kv,以示,new 来源: https://www.cnblogs.com/luludongxu/p/14982092.html