C# Language Preprocessor directives Region Blocks

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Use #region and #endregion to define a collapsible code region.

#region Event Handlers

public void Button_Click(object s, EventArgs e)
{
    // ...
}

public void DropDown_SelectedIndexChanged(object s, EventArgs e)
{
    // ...
}

#endregion

These directives are only beneficial when an IDE that supports collapsible regions (such as Visual Studio) is used to edit the code.



Got any C# Language Question?