Debug.Write Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Escreve informações sobre a depuração para os ouvintes de traços na Listeners coleção.
Sobrecargas
| Name | Description |
|---|---|
| Write(String, String) |
Escreve um nome de categoria e uma mensagem para os ouvintes de rastreamento na Listeners coleção. |
| Write(Object, String) |
Escreve um nome de categoria e o valor do método do objeto ToString() para os ouvintes de traços na Listeners coleção. |
| Write(Object) |
Escreve o valor do método do ToString() objeto para os ouvintes de traços na Listeners coleção. |
| Write(String) |
Escreve uma mensagem para os ouvintes de rastreamento na Listeners coleção. |
Write(String, String)
Escreve um nome de categoria e uma mensagem para os ouvintes de rastreamento na Listeners coleção.
public:
static void Write(System::String ^ message, System::String ^ category);
[System.Diagnostics.Conditional("DEBUG")]
public static void Write(string message, string category);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Write : string * string -> unit
Public Shared Sub Write (message As String, category As String)
Parâmetros
- message
- String
Uma mensagem para escrever.
- category
- String
Um nome de categoria usado para organizar a saída.
- Atributos
Exemplos
O exemplo seguinte cria um TraceSwitch .generalSwitch Este interruptor está definido fora do exemplo de código.
Se o interruptor estiver definido para ou TraceLevelError superior, o exemplo envia a primeira mensagem de erro para o Listeners. Para informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection aula.
Então, se o TraceLevel for definido para Verbose, o exemplo gera a segunda mensagem de erro na mesma linha da primeira mensagem. Um terminador de linha segue a segunda mensagem.
// Class-level declaration.
// Create a TraceSwitch.
static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");
static public void MyErrorMethod(Object myObject, string category)
{
// Write the message if the TraceSwitch level is set to Error or higher.
if (generalSwitch.TraceError)
Debug.Write(myObject, category);
// Write a second message if the TraceSwitch level is set to Verbose.
if (generalSwitch.TraceVerbose)
Debug.WriteLine(" Object is not valid for this category.");
}
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")
Public Shared Sub MyErrorMethod(myObject As Object, category As String)
' Write the message if the TraceSwitch level is set to Error or higher.
If generalSwitch.TraceError Then
Debug.Write(myObject, category)
End If
' Write a second message if the TraceSwitch level is set to Verbose.
If generalSwitch.TraceVerbose Then
Debug.WriteLine(" Object is not valid for this category.")
End If
End Sub
Observações
Por defeito, a saída é escrita numa instância de DefaultTraceListener.
Use o category parâmetro para agrupar as mensagens de saída.
Este método chama o Write método do ouvinte de traços.
Ver também
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Aplica-se a
Write(Object, String)
Escreve um nome de categoria e o valor do método do objeto ToString() para os ouvintes de traços na Listeners coleção.
public:
static void Write(System::Object ^ value, System::String ^ category);
[System.Diagnostics.Conditional("DEBUG")]
public static void Write(object value, string category);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Write : obj * string -> unit
Public Shared Sub Write (value As Object, category As String)
Parâmetros
- category
- String
Um nome de categoria usado para organizar a saída.
- Atributos
Exemplos
O exemplo seguinte cria um TraceSwitch .generalSwitch Este interruptor está definido fora do exemplo de código.
Se o interruptor estiver definido para ou TraceLevelError superior, o exemplo envia a primeira mensagem de erro para o Listeners. Para informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection aula.
Então, se o TraceLevel for definido para Verbose, o exemplo gera a segunda mensagem de erro na mesma linha da primeira mensagem. Um terminador de linha segue a segunda mensagem.
// Class-level declaration.
// Create a TraceSwitch.
static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");
static public void MyErrorMethod(Object myObject, string category)
{
// Write the message if the TraceSwitch level is set to Error or higher.
if (generalSwitch.TraceError)
Debug.Write(myObject, category);
// Write a second message if the TraceSwitch level is set to Verbose.
if (generalSwitch.TraceVerbose)
Debug.WriteLine(" Object is not valid for this category.");
}
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")
Public Shared Sub MyErrorMethod(myObject As Object, category As String)
' Write the message if the TraceSwitch level is set to Error or higher.
If generalSwitch.TraceError Then
Debug.Write(myObject, category)
End If
' Write a second message if the TraceSwitch level is set to Verbose.
If generalSwitch.TraceVerbose Then
Debug.WriteLine(" Object is not valid for this category.")
End If
End Sub
Observações
Por defeito, a saída é escrita numa instância de DefaultTraceListener.
Use o category parâmetro para agrupar as mensagens de saída.
Este método chama o Write método do ouvinte de traços.
Ver também
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Aplica-se a
Write(Object)
Escreve o valor do método do ToString() objeto para os ouvintes de traços na Listeners coleção.
public:
static void Write(System::Object ^ value);
[System.Diagnostics.Conditional("DEBUG")]
public static void Write(object value);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Write : obj -> unit
Public Shared Sub Write (value As Object)
Parâmetros
- Atributos
Exemplos
O exemplo seguinte cria um TraceSwitch .generalSwitch Este interruptor está definido fora do exemplo de código.
Se o interruptor estiver definido para ou TraceLevelError superior, o exemplo envia a primeira mensagem de erro para o Listeners. Para informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection aula.
Então, se o TraceLevel for definido para Verbose, o exemplo gera a segunda mensagem de erro na mesma linha da primeira mensagem. Um terminador de linha segue a segunda mensagem.
// Class-level declaration.
// Create a TraceSwitch.
static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");
static public void MyErrorMethod(Object myObject, string category)
{
// Write the message if the TraceSwitch level is set to Error or higher.
if (generalSwitch.TraceError)
Debug.Write(myObject, category);
// Write a second message if the TraceSwitch level is set to Verbose.
if (generalSwitch.TraceVerbose)
Debug.WriteLine(" Object is not valid for this category.");
}
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")
Public Shared Sub MyErrorMethod(myObject As Object, category As String)
' Write the message if the TraceSwitch level is set to Error or higher.
If generalSwitch.TraceError Then
Debug.Write(myObject, category)
End If
' Write a second message if the TraceSwitch level is set to Verbose.
If generalSwitch.TraceVerbose Then
Debug.WriteLine(" Object is not valid for this category.")
End If
End Sub
Observações
Por defeito, a saída é escrita numa instância de DefaultTraceListener.
Este método chama o Write método do ouvinte de traços.
Ver também
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Aplica-se a
Write(String)
Escreve uma mensagem para os ouvintes de rastreamento na Listeners coleção.
public:
static void Write(System::String ^ message);
[System.Diagnostics.Conditional("DEBUG")]
public static void Write(string message);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Write : string -> unit
Public Shared Sub Write (message As String)
Parâmetros
- message
- String
Uma mensagem para escrever.
- Atributos
Exemplos
O exemplo seguinte cria um TraceSwitch .generalSwitch Este interruptor está definido fora do exemplo de código.
Se o interruptor estiver definido para ou TraceLevelError superior, o exemplo envia a primeira mensagem de erro para o Listeners. Para informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection aula.
Então, se o TraceLevel for definido para Verbose, o exemplo gera a segunda mensagem de erro na mesma linha da primeira mensagem. Um terminador de linha segue a segunda mensagem.
// Class-level declaration.
// Create a TraceSwitch.
static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");
static public void MyErrorMethod(Object myObject, string category)
{
// Write the message if the TraceSwitch level is set to Error or higher.
if (generalSwitch.TraceError)
Debug.Write(myObject, category);
// Write a second message if the TraceSwitch level is set to Verbose.
if (generalSwitch.TraceVerbose)
Debug.WriteLine(" Object is not valid for this category.");
}
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")
Public Shared Sub MyErrorMethod(myObject As Object, category As String)
' Write the message if the TraceSwitch level is set to Error or higher.
If generalSwitch.TraceError Then
Debug.Write(myObject, category)
End If
' Write a second message if the TraceSwitch level is set to Verbose.
If generalSwitch.TraceVerbose Then
Debug.WriteLine(" Object is not valid for this category.")
End If
End Sub
Observações
Por defeito, a saída é escrita numa instância de DefaultTraceListener.
Este método chama o Write método do ouvinte de traços.
Ver também
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute