相关疑难解决方法(0)

C#接口静态方法调用泛型

有没有一种简单的方法来实现它,如果可能的话,不需要实例化对象:

interface I
{
     static  string GetClassName();
}

public class Helper
{

    static void PrintClassName<T>() where T : I
    {
         Console.WriteLine(T.GetClassName());
    }
}
Run Code Online (Sandbox Code Playgroud)

c# generics inheritance static interface

28
推荐指数
2
解决办法
3万
查看次数

标签 统计

c# ×1

generics ×1

inheritance ×1

interface ×1

static ×1