Type.GetGenericArguments and MethodInfo.GetGenericArguments : Type : Reflection C# Source Code


Custom Search

C# Source Code » Reflection » Type »

 

Type.GetGenericArguments and MethodInfo.GetGenericArguments








    
 

using System;


class MyClass<K, V> {
    public void FunctionA(K argk, V argv) {

    }
}

class Starter {

    public static void Main() {
        MyClass<int, decimal> obj = new MyClass<int, decimal>();
        MyClass<string, float> obj2 = new MyClass<string, float>();

        Type closedType = obj.GetType();
        Type openType = closedType.GetGenericTypeDefinition();

        Type closedType2 = obj2.GetType();
        Type openType2 = closedType2.GetGenericTypeDefinition();

        Console.WriteLine(openType.ToString());
        Console.WriteLine(openType2.ToString());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Reflection
» Type