小编klm*_*lm_的帖子

在基本静态类中获取继承的调用者类型名称

我有:

class parent
{
    public static string GetTypeName()
    { 
        /* here i want to get the caller's type
        So child.GetTypeName() should display "child" */
    }            
}     

class child : parent { }

static void Main()
{
    Console.WriteLine(child.GetTypeName());
}
Run Code Online (Sandbox Code Playgroud)

有可能以某种方式在基类中获取调用者的类型吗?

.net c# inheritance

3
推荐指数
1
解决办法
2145
查看次数

标签 统计

.net ×1

c# ×1

inheritance ×1