Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# reflection invoke static generic method

//If we want to call the GenericMethod with type string.
var sample = new Sample(); //or you can get an instance via reflection
var method = typeof(Sample).GetMethod("GenericMethod");
var generic = method.MakeGenericMethod(typeof(string));
generic.Invoke(sample, null);//Since there are no arguments, we are passing null

//For the static method you do not need an instance. Therefore the first argument will also be null.
var method = typeof(Sample).GetMethod("StaticMethod");
var generic = method.MakeGenericMethod(typeof(string));
generic.Invoke(null, null);
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# change cursor 
Csharp :: executable path with app name c# 
Csharp :: wpf fixed size window 
Csharp :: iterate through dictionary c# 
Csharp :: random.range unity 
Csharp :: Unity Scene Load by Name 
Csharp :: unity if or 
Csharp :: c# 8 null coalescing assignment 
Csharp :: c# start as adminstrator 
Csharp :: link nuttom in c# 
Csharp :: unity rotate vector around point 
Csharp :: Unity C# make object face away 
Csharp :: wpf make both rich Text scroll 
Csharp :: audiomixer get float 
Csharp :: using tmp unity 
Csharp :: system.linq.iorderedenumerable`2[system.char,system.char] çözümü 
Csharp :: how to get element dictionary key in c# by index 
Csharp :: c sharp check if key in dictionary 
Csharp :: c# close 1 form open another form 
Csharp :: object list to csv c# 
Csharp :: how to destroy an object in unity 
Csharp :: unity get rigidbody 
Csharp :: how to take user input in string in c# 
Csharp :: how to check if string can be converted to int c# 
Csharp :: c# regex to find number between parenthesis 
Csharp :: west of loathing 
Csharp :: c# choose first n elements from list 
Csharp :: unity change tmp text from script 
Csharp :: c# OnMouseUp unity 
Csharp :: c# combobox selectedvalue 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =