demonstrates both the instance and static GetType methods : Type : Reflection C# Source Code


Custom Search

C# Source Code » Reflection » Type »

 

demonstrates both the instance and static GetType methods








    
 

using System;


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

class XClass<T> {
    public void FunctionB(T argt) {
    }
}

class Starter {

    public static void Main() {
        MyClass<int, decimal> obj = new MyClass<int, decimal>();
        Type typeClosed = obj.GetType();
        Console.WriteLine(typeClosed.ToString());

        Type typeOpen = Type.GetType("Donis.CSharpBook.XClass`1");
        Console.WriteLine(typeOpen.ToString());
        Type typeClosed2 = Type.GetType(
            "Donis.CSharpBook.MyClass`2[System.Int32, System.Decimal]");
        Console.WriteLine(typeClosed2.ToString());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Reflection
» Type