簡體   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