2 ms·
Does C# not use the same default of non-inheritable classes? Or is it just at the method level, where you have to mark methods as overridable?
by masklinn 15y ago
Does C# not use the same default of non-inheritable classes? Or is it just at the method level, where you have to mark methods as overridable?
- dmcg 15y agoYou have to mark methods as virtual - I believe classes are by default.
- ppog 15y agoClasses in C# are inheritable by default, as in Java, but can be marked sealed (final). Members (methods and properties) in C# are final by default, and must be explicitly marked virtual.
- frou_dh 15y agoFor what it's worth, Jon Skeet of StackOverflow fame and C# fanaticism, thinks C# classes should also be sealed by default. "I'd say it was just a mistake. I know many people (including myself) who believe that classes should indeed be sealed by default. There are at least a couple of people in the C# design team in that camp. The pendulum has swung somewhat away from inheritance since C# was first designed. (It has its place, of course, but I find myself using it relatively rarely.)"
- masklinn 15y agoAh, that's where I got confused, I remembered there was something in C# which made classes not-really-inheritable by default but had no way to test it.