C# Get Name of Derived Type from Inside base Class

this.GetType().Name should work. I think, in your case, you may not have a derived class. If it’s returning the base class name, it shouldn’t have a derived class.

Using this on:

  1. Base class – Outputs Base class name
  2. Derived class – Outputs Derived class name
  3. Derived class cast to Base class – Outputs Derived class name
  4. Derived class passed into a function that accepts Base class as a parameter – Outputs Derived class name

Leave a Comment