Regain/EndRegain  
Author Message
xlordt





PostPosted: Visual C# Language, Regain/EndRegain Top

Sometimes I see some coeds that starts with #regain with some other codes in it and ends with #endregain... what is this for and what does it mean I have a c# book its there.. but cant find were it explains it. Also what good is it for



Visual C#10  
 
 
ahmedilyas





PostPosted: Visual C# Language, Regain/EndRegain Top

i dont think there is a "regain" but a "region"

its basically for you to allow you to expand/collapse code in between the "markers". The compiler ignores these bookmarks and is only for our readability purposes.

you place your code in between the comments/bookmarks so you can easily navigate or arrange the code. So you can have this code:

#region

string test = String.Empty;

#endregion

and you can expand or collapse this "node". When collapsed, you can drag this code around instead of having to copy and paste a large chunk of code.



 
 
xlordt





PostPosted: Visual C# Language, Regain/EndRegain Top

Ahh I see so then I guess I dont need to learn that, correct because.. Im writing things via a programmers editor :) thanx.. although Its still good to know.


 
 
ahmedilyas





PostPosted: Visual C# Language, Regain/EndRegain Top

thats right. it gets ignored by the compiler. It's only for our benefit really, and is very useful especially if developing large bits of code and organsing your code and making it easier to go to a specific section

 
 
James Curran





PostPosted: Visual C# Language, Regain/EndRegain Top

Note also, that #region/#endregion is actually only used by your text editor, and most don't recognize it. THe tags were created by Microsoft for VIsualStudio, and some other text editor for programmers have started to as well (I believe #developer does), but more general purpose text editors (like notepad) never will.