我正在尝试创建具有以下类型的对象:
System.Collections.Generic.SortedDictionary`2+ValueCollection
当我运行fllwing命令时:
Console.WriteLine(typeof(SortedDictionary<string, object>));我得到以下输出:
System.Collections.Generic.SortedDictionary`2
我如何创建一个对象
(TheType) == System.Collections.Generic.SortedDictionary`2 ==System.Collections.Generic.SortedDictionary`2
发布于 2022-06-27 13:15:07
SortedDictionary.ValueCollection Class是一个嵌套类。SortedDictionary<TKey,TValue>的作用类似于此ValueCollection的命名空间
Console.WriteLine(typeof(SortedDictionary<string, object>.ValueCollection));
sortedDictionary = new SortedDictionary<string, object>();
var valueCollection =
new SortedDictionary<string, object>.ValueCollection(sortedDictionary);但是,SortedDictionary<TKey,TValue>会在内部自动创建这样的ValueCollection。因此,您不需要自己创建它。它由字典的Values属性返回。
发布于 2022-06-27 13:18:00
"typeof(SortedDictionary)“将返回SortedDictionaryé创建的程序集中的路径。
你可以的
SortedDictionary.Add("test", new object[]);在其中执行foreach或获取其中的值
类型(TheType) == System.Collections.Generic.SortedDictionary`2 +ValueCollection
如果你想比较,你可以用
typeof(TheType) == typeof(SortedDictionary.key)
typeof(TheType) == typeof(SortedDictionary.value)https://stackoverflow.com/questions/72772664
复制相似问题