how to I get the class name when I am passing in a genertic in my method?

Posted by Blankman on Stack Overflow See other posts from Stack Overflow or by Blankman
Published on 2010-03-28T22:39:59Z Indexed on 2010/03/28 22:43 UTC
Read the original article Hit count: 146

Filed under:
|

My method looks like:

public string DoObjectProperties<T>(T obj, string text)
{

}

Now from within the method, I need to get the string value of the class name that i pass into the method's 'obj' parameter.

So if I pass in the User object, I need the text 'user'.

To get the properties I am using: typeof(T).GetProperties()

How can I get the classes name?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection