문제

In the MSDN C# programming guide, it is mentioned that:

"A class member, method, field, property, or event, on a derived class that is overriding a virtual member of the base class can declare that member as sealed."

I understand the above statement for methods, properties and events, but how is the above statement valid for fields of a class? I tried this in a program and verified that a field cannot be virtual and hence cannot be overridden. So how can it be sealed then? And if it cannot, should the above statement from the MSDN reference have left out mention of field?

Thanks.

도움이 되었습니까?

해결책

That is indeed an error on that page.

The sealed keyword is not applicable to fields.

다른 팁

The sealed keyword is not applicable to fields, according to the C# Language Specification

In particular notice the grammar reference in Appendix C

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top