Regions
suggest changeA region is a collapsible block of code, that can help with the readability and organisation of your code.
NOTE: StyleCop’s rule SA1124 DoNotUseRegions discourages use of regions. They are usually a sign of badly organized code, as C# includes partial classes and other features which make regions obsolete.
You can use regions in the following way:
class Program
{
#region Application entry point
static void Main(string[] args)
{
PrintHelloWorld();
System.Console.ReadLine();
}
#endregion
#region My method
private static void PrintHelloWorld()
{
System.Console.WriteLine("Hello, World!");
}
#endregion
}
When the above code is view in an IDE, you will be able to collapse and expand the code using the + and - symbols.
Expanded
Collapsed
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents