Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
hi
what does #region and #endregion means??
for eg.
C#
#region
if (IsPass())
{
    Console.WriteLine("You won the game!");
}
#endregion

what does this #region do??
Posted
Updated 1-Jul-14 16:36pm
v2
Comments
[no name] 1-Jul-14 22:24pm    
Try google and you get: http://msdn.microsoft.com/en-us/library/9a1ybwek.aspx
[no name] 1-Jul-14 22:47pm    
thank you i should have goggled it first
Bernhard Hiller 2-Jul-14 2:27am    
If you find it inside a function: that is a "code smell" for bad code!

 
Share this answer
 
Comments
[no name] 1-Jul-14 22:47pm    
Thank you
Region means Territorizing your code. Which means if i say something like below:

#region log

some code

#endregion


If you minimize the above region you will observe that only the name "log" appears. This shows the developer that only log related code is present in this territory.

I have thousands of lines of code, then how do i pick only the relevant code which i want to work on and let us say that the developer who wrote the code is on leave. So in this case you will have a night mare reading all unwanted code which you dont even want to touch.

See, even classes give you good isolation, but within the class too you might want to separate out the functionality to avoid confusion.

Hence region helps maintain the code.


Thanks and Regards,
Rahul
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900