Visual Studio C# statement collapsing

前端 未结 12 1953
闹比i
闹比i 2020-11-30 17:23

When editing really long code blocks (which should definitely be refactored anyway, but that\'s beyond the scope of this question), I often long for the ability to collapse

12条回答
  •  攒了一身酷
    2020-11-30 17:57

    I'm not aware of add-ins, but you mentioned regions and I see nothing wrong with doing something like this...

    foreach (Item i in Items)
    {
      #region something big happening here
      ...
      #endregion
    
      #region something big happening here too
      ...
      #endregion
    
      #region something big happening here also
      ...
      #endregion
    }
    

    EDIT: In response to the question's EDIT: You're right, sticking a bunch of regions everywhere isn't ideal and refactoring is probably the way to go. But it seems that you're looking for something magical that will "organize" the code for you, and I don't think that exists.

提交回复
热议问题