NET.createGeneric
Create instance of specialized .NET generic type
Syntax
Description
genObj = createGeneric(
creates a handle to an object of generic type className
,paramTypes
)className
.
genObj = createGeneric(
creates an object using constructor arguments className
,paramTypes
,ctorArgs
)ctorArgs
.
Examples
Create List of System.Double
Objects
Create a strongly typed list of objects of type
System.Double
.
t = NET.createGeneric('System.Collections.Generic.List',{'System.Double'});
Modify List of Key/Value Pairs
Create the kvpType
generic association where
Key
is of type System.Int32
and
Value
is a System.String
object.
kvpType = NET.GenericClass(... 'System.Collections.Generic.KeyValuePair',... 'System.Int32','System.String');
Create the list kvpList
with initial storage capacity for 10
key-value pairs.
kvpList = NET.createGeneric('System.Collections.Generic.List',{kvpType},10);
Create a KeyValuePair
item.
kvpItem = NET.createGeneric(... 'System.Collections.Generic.KeyValuePair',... {'System.Int32','System.String'},... 42,'myString');
Add this item to the list kvpList
.
Add(kvpList,kvpItem)
Input Arguments
className
— Generic type name
string | character vector
Generic type name, specified as a string or a character vector. The name includes the fully qualified generic type name.
Example: 'System.Collections.Generic.KeyValuePair'
paramTypes
— Parameter types
cell array of strings | cell array of character vectors | NET.GenericClass
Parameter types, specified as a cell array of strings or character vectors with
fully qualified parameter type names or an instance of the NET.GenericClass
class when parameterization with another parameterized type
is needed.
ctorArgs
— Constructor arguments
valid argument types
Constructor arguments, specified as valid argument types.
ctorArgs
is a variable length (0 to N) list of constructor
arguments matching the arguments of the .NET generic class constructor.
Version History
Introduced in R2009a
See Also
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)