简体   繁体   中英

How do I set a dictionary size for Activator.CreateInstance?

我想用Activator.CreateInstance设置字典的初始大小,请问是什么语法?

var collection = Activator.CreateInstance(someDictionaryType) as IDictionary; 

如果您想使用表示容量的int参数调用Dictionary构造函数 ,请传递具有单个元素的object数组 - 大小:

var collection = Activator.CreateInstance(someDictionaryType, new object[] {123}) as IDictionary; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM