Is #region really necessary in C# coding?

956 views Asked by At

I'm just curious if #region is really necessary in C# coding, because I don't think I really need it since I can keep track of everything I do(mostly because the projects are small).

So is it really necessary to learn at all? Good and strong responses to why and why not are very welcome!

1

There are 1 answers

6
itsmatt On BEST ANSWER

No, it isn't necessary and some would say that it isn't even useful.

Personally, I'll use regions if it makes sense to group functionality together - related unit tests, for instance is a place that I'll use regions - but I know that folks differ on this opinion.

The whole point with regions is that it is simply a convenience for collapsing an area of code. It doesn't enforce anything, doesn't check that you've not put functions in the wrong place, etc. But it can be helpful in certain circumstances.