Is the #region directive really useful in .NET?

后端 未结 17 2084
孤城傲影
孤城傲影 2021-01-03 23:43

After maintaining lots of code littered with #region (in both C# and VB.NET), it seems to me that this construct is just a bunch of \"make work\" for the programmer. It\'s w

17条回答
  •  余生分开走
    2021-01-04 00:10

    I often use them instead of comments to order groups of functionality in the body of a class, e.g. "Configuration public interface", "Status public interface", "internal processing" and "internal worker thread management".

    Using the keyboard shortcuts to "collapse to definitions" and "expand current block", I can easily navigate even larger classes.

    Unfortunately, Regions are broken for C++, and MS doesn't think it needs to be fixed.

提交回复
热议问题