Whats the utility of public constructors in abstract classes in C#?

前端 未结 3 1296
不思量自难忘°
不思量自难忘° 2020-12-15 17:29

If a public constructor in an abstract class can only be called by their derived classes it should be functionally equivalent to a protected constructor. Right?

Is t

3条回答
  •  生来不讨喜
    2020-12-15 17:37

    Yes, you are right, practically public constructor has no use in abscract class as you cant create them.

    However compiler will not complain because that way there are so many useless things you can write in context of c#, but it will not be able to check its logical meaning, it can only check the parsing rules which it is set for.

    And sure c# creators have focused on creating compilation grammar (rules) that are actual harmful and violating the language use.

提交回复
热议问题