Vadim Gussak Vadim Gussak - 4 months ago 9
Vb.net Question

Hi, is there any way I can sort my code in Subs, such as in VB in C#

last year I did I class in VB at my school and at some point learnt a really useful way of sorting my code (through Private Sub / End Sub statements.) I've been starting to code in C# and was wondering if there is any way of doing this in C#

I would greatly appreciate and help, thanks.

Answer

this should do it:

#region
//code code code
#endregion

by writing #region and #endregion, anything between the two can be folded down without changing anything regarding the functionality of the code. you can event add a title to the folded area as such:

#region Math Functions

private int Add(int x, int y)
{
  // some code here
}

private int Sub(int x, int y)
{
  // some code here
}

private int Mult(int x, int y)
{
  // some code here
}

#endregion