Get actual type of T in a generic List

前端 未结 4 1099
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 01:44

How do I get the actual type of T in a generic List at run time using reflection?

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-14 02:02

    New solution old problem by dynamic

    void Foo(){
       Type type GetTypeT(data as dynamic);
    }
    
    private static Type GetTypeT(IEnumerable data)
    {
        return typeof(T);
    }
    

提交回复
热议问题