Reputation: 595
I have a class :
Class MyClass
{
...
}
I need to get the type of the class in order to use it in reflection:
string className="MyClass";
var type1=Type.GetType(className, true); //I have a problem loading the class here.
Upvotes: 1
Views: 721
Reputation: 39085
You don't necessarily need the name, you can directly do:
var type1 = typeof(MyClass);
Upvotes: 2
Reputation: 172378
You can try to use Type Properties
typeof(T).Name
and if you are dealing with instance then
this.GetType().Name
Upvotes: 5