繁体   English   中英

为什么 static class 的 Type 属性在 C# 中显示“抽象”?

[英]Why does the Type attribute of a static class show "abstract" in C#?

主要代码:

public class ReflectionsDemo
{
    public void demo()
    {
        Type t = typeof(StaticClassDemo);
        Console.WriteLine(t.Attributes);
    
    }
}

StaticClassDemo只是一个 static class 和几个 static 方法。

Output:自动布局,AnsiClass,Class,公共,抽象,密封

我不明白 static class 不会是抽象 class,但为什么它具有抽象作为属性?

“抽象”的意思是“你不能创建这种类型的实例”

“密封”的意思是“你不能从这种类型继承”

如果您稍微眯起眼睛,他们会一起描述 static class。

static class ”功能从一开始就没有,所以我假设创建者没有引入新属性来描述它,而是使用了这些现有属性的组合。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM