24.5. #region and #endregion

You can mark arbitrary sections of your code using region names using the #region and #endregion directives. These directives are totally ignored by most compilers but may be useful for C# IDEs (such as VS .NET), which may use regions defined this way for special display purposes.

An IDE may want to demarcate a source file into several regions and insert these region directives 'behind the scenes'. When the source is displayed within the IDE, these directives are usually not displayed, but used internally by the IDE.

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.