region、endregionregion, endregion

#pragma region 允许您指定的可以展开或折叠时使用的代码块大纲功能的 Visual Studio 代码编辑器中。#pragma region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.

语法Syntax

#pragma region name
#pragma endregion comment

参数Parameters

commentcomment
(可选)在代码编辑器中将显示注释。(Optional) A comment that will display in the code editor.

namename
(可选)区域的名称。(Optional) The name of the region. 此名称将显示在代码编辑器中。This name will display in the code editor.

备注Remarks

#pragma endregion 标记的末尾#pragma region块。#pragma endregion marks the end of a #pragma region block.

一个#region块必须终止与#pragma endregionA #region block must be terminated with #pragma endregion.

示例Example

// pragma_directives_region.cpp
#pragma region Region_1
void Test() {}
void Test2() {}
void Test3() {}
#pragma endregion Region_1

int main() {}

请参阅See Also

Pragma 指令和 __Pragma 关键字Pragma Directives and the __Pragma Keyword