简体   繁体   English

VS2015,#endregion 丢失了怎么找?

[英]VS2015, #endregion is missing how to find it?

有没有快速的方法可以找到隐藏在代码中的缺失 #endregion,编译器错误总是指向 C# 代码的结尾,而没有指示它在哪里丢失。

Ctrl + Shift + F for a #region|#endregion with regex flag on. Ctrl + Shift + F用于打开正则表达式标志的#region|#endregion Then look through search results for correct structure.然后查看搜索结果以获取正确的结构。 If you do not have nested regions, they should alternate.如果您没有嵌套区域,它们应该交替。 If you have, I expect you to have correct indents, so first #region without #endregion with same indent in previous line is what you are looking for.如果你有,我希望你有正确的缩进,所以第一个#region没有#endregion与前一行相同的缩进是你正在寻找的。

Note that you can use Ctrl + Shift + F for searching in a single file too.请注意,您也可以使用Ctrl + Shift + F在单个文件中进行搜索。

  1. Press Ctrl + M , O // Collapse all functions and regions;按 Ctrl + M , O // 折叠所有功能和区域;
  2. Press Ctrl + F and type #region // Scroll down from Begin of the class;按 Ctrl + F 并输入 #region // 从类的开始向下滚动;
  3. It will clearly show like below Screenshot with no + sign but other region will have + sign;它将清楚地显示如下屏幕截图,没有 + 号,但其他区域会有 + 号;
  4. You can notice closed-region will be collapsed in grey color and '#region' will be not visible but open-region will be shown as in the Screenshot;您会注意到封闭区域将以灰色折叠并且“#region”将不可见,但开放区域将如屏幕截图所示;
  5. Note : If you don't know where should be the #endregion, then either delete the '#region' or write #endregion just below the start #region;注意:如果你不知道#endregion 应该在哪里,那么要么删除'#region',要么在开始#region 的正下方写上#endregion;
  6. Then error will boom.那么错误就会激增。

截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM