C# 从基类内部获取派生类型的名称 [英] C# Get Name of Derived Type from Inside base Class

查看:48
本文介绍了C# 从基类内部获取派生类型的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试会话期间,在特定实例的调试信息中识别实际派生类的名称对我来说很重要.

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.

我尝试使用 this.GetType().Name 但这只是返回 base 类的类型.

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?

推荐答案

this.GetType().Name 应该可以工作.您可能没有派生类.

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

这篇关于C# 从基类内部获取派生类型的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆