DefaultTraceListener.Write(String) 方法

定义

将输出写入 OutputDebugString 函数和 Log(Int32, String, String) 方法。Writes the output to the OutputDebugString function and to the Log(Int32, String, String) method.

public:
 override void Write(System::String ^ message);
public override void Write (string? message);
public override void Write (string message);
override this.Write : string -> unit
Public Overrides Sub Write (message As String)

参数

message
String

要写入 OutputDebugStringLog(Int32, String, String) 的消息。The message to write to OutputDebugString and Log(Int32, String, String).

示例

下面的代码示例设置函数结果的格式,并使用 Write(String) 方法将消息的第一部分写入 DefaultTraceListenerThe following code example formats the results of a function and uses the Write(String) method to write the first part of the message to a DefaultTraceListener.

// Compute the next binomial coefficient.
// If an exception is thrown, quit.
decimal result = CalcBinomial(possibilities, iter);
if (result==0) {return;}

// Format the trace and console output.
string binomial = String.Format("Binomial( {0}, {1} ) = ", possibilities, iter);
defaultListener.Write(binomial);
defaultListener.WriteLine(result.ToString());
Console.WriteLine("{0} {1}", binomial, result);
' Compute the next binomial coefficient.  
' If an exception is thrown, quit.
Dim result As Decimal = CalcBinomial(possibilities, iter)
If result = 0 Then Return

' Format the trace and console output.
Dim binomial As String = String.Format( _
        "Binomial( {0}, {1} ) = ", possibilities, iter)
defaultListener.Write(binomial)
defaultListener.WriteLine(result.ToString)
Console.WriteLine("{0} {1}", binomial, result)

注解

有关 Win32 OutputDebugString 调试函数的信息,请参阅平台 SDK 或 MSDN 中的 "OutputDebugString"。For information about the Win32 OutputDebugString debugging function, see "OutputDebugString" in the Platform SDK or MSDN.

适用于

另请参阅