NET.createGeneric
创建 .NET 泛型类型专用实例
说明
genObj = createGeneric(
创建一个泛型类型 className
,paramTypes
)className
对象的句柄。
genObj = createGeneric(
使用构造函数参量 className
,paramTypes
,ctorArgs
)ctorArgs
创建一个对象。
示例
创建 System.Double
对象的列表
创建一个 System.Double
类型的对象的强定型列表。
t = NET.createGeneric('System.Collections.Generic.List',{'System.Double'});
修改键/值对组列表
创建 kvpType
泛型关联,其中 Key
是 System.Int32
类型,Value
是 System.String
对象。
kvpType = NET.GenericClass(... 'System.Collections.Generic.KeyValuePair',... 'System.Int32','System.String');
创建初始存储容量为 10 个键/值对组的列表 kvpList
。
kvpList = NET.createGeneric('System.Collections.Generic.List',{kvpType},10);
创建一个 KeyValuePair
项。
kvpItem = NET.createGeneric(... 'System.Collections.Generic.KeyValuePair',... {'System.Int32','System.String'},... 42,'myString');
将该项添加到列表 kvpList
中。
Add(kvpList,kvpItem)
输入参数
className
— 泛型类型名称
字符串 | 字符向量
泛型类型名称,指定为字符串或字符向量。该名称包括完全限定的泛型类型名称。
示例: 'System.Collections.Generic.KeyValuePair'
paramTypes
— 参数类型
字符串元胞数组 | 字符向量元胞数组 | NET.GenericClass
参数类型,指定为带完全限定参数类型名称的字符串或字符向量元胞数组,或 NET.GenericClass
类的实例(需要用另一个参数化类型进行参数化时)。
ctorArgs
— 构造函数参量
有效参量类型
构造函数参量,指定为有效的参量类型。ctorArgs
是与 .NET 泛型类构造函数匹配的可变长度(0 到 N)的构造函数参量列表。
版本历史记录
在 R2009a 中推出
另请参阅
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)