TextTransformation.WriteLine 方法 (String)
将指定的字符串副本和默认的行终止符追加到生成的文本输出。
命名空间: Microsoft.VisualStudio.TextTemplating
程序集: Microsoft.VisualStudio.TextTemplating.11.0(在 Microsoft.VisualStudio.TextTemplating.11.0.dll 中)
语法
声明
Public Sub WriteLine ( _
textToAppend As String _
)
public void WriteLine(
string textToAppend
)
public:
void WriteLine(
String^ textToAppend
)
member WriteLine :
textToAppend:string -> unit
public function WriteLine(
textToAppend : String
)
参数
- textToAppend
类型:System.String
要写入的字符串。
异常
异常 | 条件 |
---|---|
ArgumentOutOfRangeException | 增大基础 StringBuilder 的值,该值将超过 MaxCapacity。 |
备注
WriteLine 方法可直接用于文本模板中。
示例
下面的代码示例演示从文本模板调用 WriteLine 方法。将此代码粘贴到任何文本模板文件中并运行文本模板转换以查看结果。
<#
string text = @"This is text to append to my output file.";
Write(text); //Using the Write method
WriteLine(null); //Using the WriteLine method
WriteLine(null); //Using the WriteLine method
for(int i=1; i<4; i++)
{
WriteLine(text); //Using the WriteLine method
}
#>
<#
Dim text as String = "This is text to append to my output file."
Dim i as Integer = 0
Write(text) 'Using the Write method
WriteLine(Nothing) 'Using the WriteLine method
WriteLine(Nothing) 'Using the WriteLine method
For i = 1 To 3
WriteLine(text) 'Using the WriteLine method
Next
#>
该示例产生下面的输出:
This is text to append to my output file.
This is text to append to my output file.
This is text to append to my output file.
This is text to append to my output file.
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualStudio.TextTemplating 命名空间