9
kjelle
8y

Fellow C# programmers, how often do you use #region in your projects and how important do you think it is?

I have found myself using it increasingly. It works great for me and I feel that I can structure my code better.

Comments
  • 1
    Never use it and why pollute ur source with this?, It can make u toggle/collapse in some editor for sure but is not that important.
  • 4
    There is the opinion that #region just gives you a better feeling when writing bad code.
    Like: oh, this method is 100 lines long. Maybe I should refactor it.... Or I wrap some of it in regions and dont have to see that shit code ever again.

    Imo there is no reason to ever use region.
  • 0
    @danielspaniol also, it just piss of people that using another text editor that didnt know how to deal with #region 😂
  • 1
    @danielspaniol While doing game projects in school I mainly use the monogame framework. Region is a bless since it lets me hide big chunks of initializing code. Call it bad code, call it what you want. It helps me very much.
  • 1
    Use it for function grouping.
  • 2
    Used it in the past. Its one more layer of structure , which can help to deal with the code or make it more complex. I prefer to make the classes themselves simpler. Cases were i often thought "hey, region would help my structure it" were often classes that I'm not really happy with.
  • 1
    I like it when I do game development with unity , but I never use it while developing UWP or WPF applications or Class libraries ...
  • 1
    our team rule is: when you need regions, your file/class is too large (we added StyleCop rules for such things - so it throws an info in VS when regions are used)
  • 0
    I really like them. Working on a huge project with some very large files that have some very large methods - regions are great for skipping over giant blocks you know you're not going to need to look at.
    Also I like having related methods close to each other.
  • 0
    I use it alot keeps code easy to find
Add Comment