C#: Is pragma warning restore needed?

If you do not restore the disabling is active for the remainder of the file.

Interestingly this behaviour is not defined in the language specification.
(see section 9.5.8) However the 9.5.1 section on Conditional compilation symbols does indicate this “until end of file behaviour”

The symbol remains defined until a
#undef directive for that same symbol is processed, or until the end of the
source file is reached.

Given the ‘pre-processor’ is actually part of the lexical analysis phase of compilation it is likely that this behaviour is an effective contract for Microsoft’s and all other implementations for the foreseeable future (especially since the alternate would be hugely complex and non deterministic based on source file compilation order)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)