C# - GetType of Object

Cyber-Drugs
Cyber-Drugs used Ask the Experts™
on
Hi guys 'n gals,

I have numberous objects, and want to determine of which type they are of, by using this:

MessageBox.Show(ObjectX.GetType().ToString());

I get this:

MyProject.MyObject


Which is nearly what I want... I want to show "MyObject", without the part on the left. I've looked through the list of methods and properties associated with GetType(), and can't seem to find what I need to do this.


Could somebody point me in the right direction please?


Cheers!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Maybe you could just override that classes "GetType" method to return only what you want. You could parse what you want out of the result of GetType().
Commented:
You mean this?
MessageBox.Show(ObjectX.GetType().Name.ToString());

Commented:
Yeah, that would be the code that you'd use in your new and improved "GetType" method. Then you parse the text to get the last bit, i.e. the "MyObject" part.

Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Author

Commented:
That did the trick dkloeck, I can't believe I missed that... I only just a moment ago noticed "FullName".

Solved! :o)

Commented:
and then just return a string instead of whatever GetType normally returns

Commented:
duh...i thought you wanted something more complicated...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial