How can i get the System.Type of a (Type in a generic function)? I need to get a string representation of the class name.
typeof(T).GetType().Name
gives me 'runtimetype', which i do not want.
How can i get the System.Type of a (Type in a generic function)? I need to get a string representation of the class name.
typeof(T).GetType().Name
gives me 'runtimetype', which i do not want.
Just do:
typeof(T)
That will result in the actual type of T
whatever T
is for that particular instance of your generic class/method. If T
happened to be System.String
, you would get an instance of the type representing System.String
.
Can you use like this ?
Type thisType = this.GetType(); // Get your current class type
thisType.FullName // Get your Assembly Name.
Edit in you class,
Type thistype = TypeOf(T);
thisType.Name // Get you class name