Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Classes 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.


For 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.)"


Ah, 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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: