共用方式為


TextTransformation.PopIndent 方法

CurrentIndent 中移除最新加入的文字。

命名空間:  Microsoft.VisualStudio.TextTemplating
組件:  Microsoft.VisualStudio.TextTemplating.11.0 (在 Microsoft.VisualStudio.TextTemplating.11.0.dll 中)

語法

'宣告
Public Function PopIndent As String
public string PopIndent()
public:
String^ PopIndent()
member PopIndent : unit -> string 
public function PopIndent() : String

傳回值

型別:System.String
String ,包含最新加入至 CurrentIndent 的文字。通常會呼叫 CurrentIndent,而不需要擷取傳回值。

備註

CurrentIndent 代表在所產生的文字輸出中每一行的前置文字。縮排文字只能是空格,例如 "    ",或者可以包含字組。PushIndent 會將文字加入至 CurrentIndent,並可被呼叫多次。PopIndent 會自 CurrentIndent 移除最近加入且可呼叫多次的文字。從 CurrentIndent 會移除 ClearIndent 中的所有文字。

範例

下列程式碼範例示範從文字範本呼叫 PopIndent 方法。將這個程式碼貼到任何文字範本檔案,並執行文字範本轉換,以查看結果。

<#
PushIndent("Indent1>  ");
PushIndent("Indent2>  ");

WriteLine("Test");

string previous = PopIndent();
WriteLine("The previous indent was: {0}", previous);

PopIndent();  //Pop without capturing the return value.
WriteLine("Test");

ClearIndent();
#>
<#
PushIndent("Indent1>  ")
PushIndent("Indent2>  ")

WriteLine("Test")

Dim previous as String = PopIndent()
WriteLine("The previous indent was: {0}", previous)

PopIndent()  'Pop without capturing the return value.
WriteLine("Test")

ClearIndent()
#>

這個範例會產生下列輸出:

Indent1> Indent2> Test

Indent1> The previous indent was: Indent2>

Test

.NET Framework 安全性

請參閱

參考

TextTransformation 類別

Microsoft.VisualStudio.TextTemplating 命名空間

CurrentIndent

PushIndent

ClearIndent

其他資源

程式碼產生和 T4 文字範本