Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# reflection create generic type

Type generic = typeof(Dictionary<,>);

// Create an array of types to substitute for the type parameters of Dictionary. The key is of type string, and the type to be contained in the Dictionary is Test.
Type[] typeArgs = { typeof(string), typeof(Test) };

// Create a Type object representing the constructed generic type.
Type constructed = generic.MakeGenericType(typeArgs);

var instance = Activator.CreateInstance(constructedType);
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# nunit test case 
Csharp :: math in c# 
Csharp :: longest palindromic substring 
Csharp :: triangle 
Csharp :: c# sort llist 
Csharp :: Proxy in Config 
Csharp :: string length f# 
Csharp :: c# out argument 
Csharp :: dateTime first/last 
Csharp :: C# date type no time 
Csharp :: calculate textbox value c# 
Csharp :: cefsharp print 
Csharp :: for loop c# to print times tables 
Csharp :: system.componentmodel.dataannotations hide field 
Csharp :: c# check multiple variables for null 
Csharp :: <link rel="stylesheet" href="styles/kendo.common.min.css" / 
Csharp :: pass viewbag selectlistitem to razor 
Csharp :: user (current login user) in viewcomponent 
Csharp :: actual vector3 object unity 
Csharp :: how to combine constructors in c# 
Csharp :: how to extract data from a document using c# 
Csharp :: array of objects c# 
Csharp :: to string c# fields 
Csharp :: Unity android plugin callback 
Csharp :: c# ? behind variable 
Csharp :: read text c# 
Csharp :: C# resize window without title bar 
Csharp :: 1180 - Lowest Number and Position C# 
Csharp :: WPF combobox filter as you type 
Csharp :: c# increment by 2 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =