Dictionary.TryGetValue中的out参数是否通过引用指向该值

Sir*_*our 8 c# dictionary reference

考虑我有一个Dictionary<Key,List<item>>TestDictionary

如果我做 :

List<item> someCollection;
TestDictionary.TryGetValue(someKey,out someCollection); //assuming that someCollection will not return null;
someCollection.add(someItem);
Run Code Online (Sandbox Code Playgroud)

将对象someItem添加到Dictionary值TestDictionary [someKey]中的集合中吗?

Ale*_*exH 11

是的,如果对象是Ref类型,您将拥有该对象的引用,当然,如果它是Value类型,则会有一个副本