Debug.Write Método

Definição

Grava informações sobre a depuração nos ouvintes de rastreamento da coleção Listeners.

Sobrecargas

Write(String, String)

Grava um nome de categoria e mensagem nos ouvintes de rastreamento da coleção Listeners.

Write(Object, String)

Grava um nome de categoria e o valor do método ToString() do objeto nos ouvintes de rastreamento da coleção Listeners.

Write(String)

Grava uma mensagem para os ouvintes de rastreamento na coleção Listeners.

Write(Object)

Grava o valor do método ToString() do objeto nos ouvintes de rastreamento da coleção Listeners.

Write(String, String)

Origem:
Debug.cs
Origem:
Debug.cs
Origem:
Debug.cs

Grava um nome de categoria e mensagem nos ouvintes de rastreamento da coleção Listeners.

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")]
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 a ser gravada.

category
String

Um nome de categoria usado para organizar a saída.

Atributos

Exemplos

O exemplo a seguir cria um TraceSwitch chamado generalSwitch. Essa opção é definida fora do exemplo de código.

Se a opção for definida como ou TraceLevelError superior, o exemplo gerará a primeira mensagem de erro para o Listeners. Para obter informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection classe .

Em seguida, se o TraceLevel estiver definido como Verbose, o exemplo gerará a segunda mensagem de erro na mesma linha que a primeira mensagem. Um terminador de linha segue a segunda mensagem.

   // Class-level declaration.
   // Create a TraceSwitch.
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General","Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject, String^ category )
   {
      // Write the message if the TraceSwitch level is set to Error or higher.
      if ( generalSwitch->TraceError )
      {
         #if defined(DEBUG)
         Debug::Write( myObject, category );
         #endif
      }
      // Write a second message if the TraceSwitch level is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
         #if defined(DEBUG)
         Debug::Write( " Object is not valid for this category." );
         #endif
      }
   }
// 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

Comentários

Por padrão, a saída é gravada em uma instância do DefaultTraceListener.

Use o category parâmetro para agrupar mensagens de saída.

Esse método chama o Write método do ouvinte de rastreamento.

Confira também

Aplica-se a

Write(Object, String)

Origem:
Debug.cs
Origem:
Debug.cs
Origem:
Debug.cs

Grava um nome de categoria e o valor do método ToString() do objeto nos ouvintes de rastreamento da coleção Listeners.

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")]
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

value
Object

Um objeto cujo nome é enviado para o Listeners.

category
String

Um nome de categoria usado para organizar a saída.

Atributos

Exemplos

O exemplo a seguir cria um TraceSwitch chamado generalSwitch. Essa opção é definida fora do exemplo de código.

Se a opção for definida como ou TraceLevelError superior, o exemplo gerará a primeira mensagem de erro para o Listeners. Para obter informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection classe .

Em seguida, se o TraceLevel estiver definido como Verbose, o exemplo gerará a segunda mensagem de erro na mesma linha que a primeira mensagem. Um terminador de linha segue a segunda mensagem.

   // Class-level declaration.
   // Create a TraceSwitch.
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General","Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject, String^ category )
   {
      // Write the message if the TraceSwitch level is set to Error or higher.
      if ( generalSwitch->TraceError )
      {
         #if defined(DEBUG)
         Debug::Write( myObject, category );
         #endif
      }
      // Write a second message if the TraceSwitch level is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
         #if defined(DEBUG)
         Debug::Write( " Object is not valid for this category." );
         #endif
      }
   }
// 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

Comentários

Por padrão, a saída é gravada em uma instância do DefaultTraceListener.

Use o category parâmetro para agrupar mensagens de saída.

Esse método chama o Write método do ouvinte de rastreamento.

Confira também

Aplica-se a

Write(String)

Origem:
Debug.cs
Origem:
Debug.cs
Origem:
Debug.cs

Grava uma mensagem para os ouvintes de rastreamento na coleção Listeners.

public:
 static void Write(System::String ^ message);
[System.Diagnostics.Conditional("DEBUG")]
public static void Write (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 a ser gravada.

Atributos

Exemplos

O exemplo a seguir cria um TraceSwitch chamado generalSwitch. Essa opção é definida fora do exemplo de código.

Se a opção for definida como ou TraceLevelError superior, o exemplo gerará a primeira mensagem de erro para o Listeners. Para obter informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection classe .

Em seguida, se o TraceLevel estiver definido como Verbose, o exemplo gerará a segunda mensagem de erro na mesma linha que a primeira mensagem. Um terminador de linha segue a segunda mensagem.

   // Class-level declaration.
   // Create a TraceSwitch.
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General","Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject, String^ category )
   {
      // Write the message if the TraceSwitch level is set to Error or higher.
      if ( generalSwitch->TraceError )
      {
         #if defined(DEBUG)
         Debug::Write( myObject, category );
         #endif
      }
      // Write a second message if the TraceSwitch level is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
         #if defined(DEBUG)
         Debug::Write( " Object is not valid for this category." );
         #endif
      }
   }
// 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

Comentários

Por padrão, a saída é gravada em uma instância do DefaultTraceListener.

Esse método chama o Write método do ouvinte de rastreamento.

Confira também

Aplica-se a

Write(Object)

Origem:
Debug.cs
Origem:
Debug.cs
Origem:
Debug.cs

Grava o valor do método ToString() do objeto nos ouvintes de rastreamento da coleção Listeners.

public:
 static void Write(System::Object ^ value);
[System.Diagnostics.Conditional("DEBUG")]
public static void Write (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

value
Object

Um objeto cujo nome é enviado para o Listeners.

Atributos

Exemplos

O exemplo a seguir cria um TraceSwitch chamado generalSwitch. Essa opção é definida fora do exemplo de código.

Se a opção for definida como ou TraceLevelError superior, o exemplo gerará a primeira mensagem de erro para o Listeners. Para obter informações sobre como adicionar um ouvinte à Listeners coleção, consulte a TraceListenerCollection classe .

Em seguida, se o TraceLevel estiver definido como Verbose, o exemplo gerará a segunda mensagem de erro na mesma linha que a primeira mensagem. Um terminador de linha segue a segunda mensagem.

   // Class-level declaration.
   // Create a TraceSwitch.
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General","Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject, String^ category )
   {
      // Write the message if the TraceSwitch level is set to Error or higher.
      if ( generalSwitch->TraceError )
      {
         #if defined(DEBUG)
         Debug::Write( myObject, category );
         #endif
      }
      // Write a second message if the TraceSwitch level is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
         #if defined(DEBUG)
         Debug::Write( " Object is not valid for this category." );
         #endif
      }
   }
// 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

Comentários

Por padrão, a saída é gravada em uma instância do DefaultTraceListener.

Esse método chama o Write método do ouvinte de rastreamento.

Confira também

Aplica-se a