Possible Duplicate:
Get type name without full namespace in C#
Does anybody know how we can get the name of a class in a simple way like what Java can do via class.getName()
?
NB: Yes, there are some messy workaround like CreateInstance
of the class type and then get the name of object but I want a simple way.
Edit 1:
Actually, I need the class name in a method say X. Meanwhile, I don't want to loose type-safety and I'm not gonna allow other developers to pass a string to the method. Something like this:
void X( ??? class) // --> don't know how
{
var className = get the name of class // --> which I don't know how
Console.WriteLine(className);
}
X(tblEmployee); //--> usage of X, where tblEmployee is a POCO class