小编caz*_*tos的帖子

为什么C#不允许typeof作为默认参数?

class MyClass
{
    public void MyMethod(Type targetType = typeof(MyClass))
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

不是typeof(MyClass)编译时常量?

c# typeof default-parameters

12
推荐指数
2
解决办法
1724
查看次数

标签 统计

c# ×1

default-parameters ×1

typeof ×1