Override and Accessibility #7258
-
Currently, when you override a member, you must restate the accessibility of the member (public, protected, etc). Is this necessarily required? Could the language be enhanced to make this optional? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I prefer the clarity. It's something the IDE will insert for you anyway. Also, the runtime doesn't require that the accessibility of overrides match the overridden member, so making it implicit could impact future language design to make overrides more flexible. |
Beta Was this translation helpful? Give feedback.
-
I kind of like C++ style accessibility regions, actually. I tend to group members by accessibility and category anyway, like public methods, public properties, etc. However, the C++ approach can be a little difficult to read in larger classes - if can be difficult to easily tell which accessibility region a given members happens to be in. Maybe it would be better with an explicit curly-brace-delimited region? That would create another indentation level, but would save a lot of the keyword clutter. Anyway, I doubt this would ever happen in C#. class Foo
{
public
{
void Bar() { ... }
}
} |
Beta Was this translation helpful? Give feedback.
I prefer the clarity. It's something the IDE will insert for you anyway. Also, the runtime doesn't require that the accessibility of overrides match the overridden member, so making it implicit could impact future language design to make overrides more flexible.