C# Get Name of Derived Type from Inside base Class

Steve picture Steve · Sep 3, 2009 · Viewed 20.3k times · Source

During a debug session, it's important for me to identify the name of the actual derived class in the debug info of specific instances.

I tried using this.GetType().Name but this simply returns the type of the base class.

Is there a simple way to get the type of the derived class from within the base class?

Answer

n8wrl picture n8wrl · Sep 3, 2009

this.GetType().Name should work. You may not have a derived class.