Returns the type of the given object.
Use typeof()
on the given object’s type.
代码实现
public static partial class _30s
{
public static Type GetType<T>(T obj)
{
return typeof(T);
}
}
使用样例
string s = "fooBar";
List<string> list = new List<string> { "a", "b", "c" };
_30s.GetType(s); // System.String
_30s.GetType(list); // System.Collections.Generic.List`1[System.String]