How do I get the type name of a generic type argument?

后端 未结 3 798
半阙折子戏
半阙折子戏 2020-12-10 00:03

If I have a method signature like

public string myMethod( ... )

How can I, inside the method, get the name of the type that was g

3条回答
  •  北海茫月
    2020-12-10 00:58

    Assuming you have some instance of a T available, it's no different than any other type.

    var t = new T();
    
    var name = t.GetType().FullName;
    

提交回复
热议问题