Hello all, a lot of times I see C# code written without the use of #region and #endregion, I'm just wondering if there is any reason not to use it, and what are your thoughts on using it.

I think it's an amazing feature that lets you clearly identify groups of functions/classes with similar functionality.

i.e.,

#region PROGRAM_INIT
//Functions to initialize variables, etc.
#endregion

#region STRUCTION
//ctor
//dtor
#endregion

#region EVENTS
//Program events go here.
#endregion
ddanbe commented: Good question. +14

I think this feature is used just like comments mean using it or not is in users hand yes you are right this feature is amazing and gives a clean look to the program

I agree with you both. Amazing feature of the editor in VS. I used to work with this editor.
I can tell you not only #region is an improvement. :|

Hey I've used VI before, it's supposed to be "powerful" somehow, but I never figured out how. It certainly isn't intuitive, or at least, the version that I used.

VI sure had its merrits in the previous century. Once you got used to it, it worked very well. Don't ask me to do anything in it now, commands all lost!
I could not miss VS, intellisence, #region and all the other goodies to program in C#.

You can also enable collapsing of things such as for loops inside of functions (for C/C++ at least).

on VS2010:
tools -> options -> text editor -> C/C++ -> Formatting -> Outlining ->
set Outline statement blocks = true.

and not to get off topic, but if someone uses F# could you give me some information about your experience learning it, or at least learning a functional language in general.

I am currently reading:
Real World Functional Programming: With Examples in F# and C# [Paperback] Tomas Petricek (Author) Jon Skeet (Author)
I must say it is quite an experience(the good way that is :) )
I would not consider this book something to learn F# with, but it compares F# and C# very well.
It will take some time to get used to, just like the VI commands.;)
Perhaps this site will consider a F# forum in the near future?

Yes I think that's a good idea also.

Regions are great, especially if you want to share your work with co-workers/other people. Regions, combined with xml commenting make for a very powerful and productive environment. Props to microsoft on doing something right (for once! :P)

I'm currently reading 3 F# books (one of which is an updated version from F# 1.1 to F# 2.0). Doing things in F# takes a little getting used to (all values are immutable be default). Some of the ideas have carried over into my C# programming (no side effects!). I believe it's worth-while to learn :)

I agree with skatamatic, regions are greate for when sharing works with co-workers, means that you can label a section of code collaps it, makes your code look cleaner and a little less over-whelming to others.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.