Debug.Write Metodo

Definizione

Scrive le informazioni sul debug nei listener di traccia dell'insieme Listeners.

Overload

Write(String, String)

Scrive un nome di categoria e un messaggio nei listener di traccia della raccolta Listeners.

Write(Object, String)

Scrive un nome di categoria e il valore del metodo ToString() dell'oggetto nei listener di traccia nella raccolta Listeners.

Write(String)

Scrive un messaggio nei listener di traccia della raccolta Listeners.

Write(Object)

Scrive il valore del metodo ToString() dell'oggetto nei listener di traccia nella raccolta Listeners.

Write(String, String)

Origine:
Debug.cs
Origine:
Debug.cs
Origine:
Debug.cs

Scrive un nome di categoria e un messaggio nei listener di traccia della raccolta 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)

Parametri

message
String

Messaggio da scrivere.

category
String

Nome di categoria usato per organizzare l'output.

Attributi

Esempio

Nell'esempio seguente viene creato un TraceSwitch oggetto denominato generalSwitch. Questa opzione viene impostata all'esterno dell'esempio di codice.

Se l'opzione è impostata su TraceLevelError o superiore, nell'esempio viene restituito il primo messaggio di errore a Listeners. Per informazioni sull'aggiunta Listeners di un listener alla raccolta, vedere la TraceListenerCollection classe .

Se l'oggetto è impostato su Verbose, l'esempio TraceLevel restituisce il secondo messaggio di errore nella stessa riga del primo messaggio. Un terminatore di riga segue il secondo messaggio.

   // 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

Commenti

Per impostazione predefinita, l'output viene scritto in un'istanza di DefaultTraceListener.

Usare il category parametro per raggruppare i messaggi di output.

Questo metodo chiama il Write metodo del listener di traccia.

Vedi anche

Si applica a

Write(Object, String)

Origine:
Debug.cs
Origine:
Debug.cs
Origine:
Debug.cs

Scrive un nome di categoria e il valore del metodo ToString() dell'oggetto nei listener di traccia nella raccolta 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)

Parametri

value
Object

Oggetto il cui nome viene inviato ai Listeners.

category
String

Nome di categoria usato per organizzare l'output.

Attributi

Esempio

Nell'esempio seguente viene creato un TraceSwitch oggetto denominato generalSwitch. Questa opzione viene impostata all'esterno dell'esempio di codice.

Se l'opzione è impostata su TraceLevelError o superiore, nell'esempio viene restituito il primo messaggio di errore a Listeners. Per informazioni sull'aggiunta Listeners di un listener alla raccolta, vedere la TraceListenerCollection classe .

Se l'oggetto è impostato su Verbose, l'esempio TraceLevel restituisce il secondo messaggio di errore nella stessa riga del primo messaggio. Un terminatore di riga segue il secondo messaggio.

   // 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

Commenti

Per impostazione predefinita, l'output viene scritto in un'istanza di DefaultTraceListener.

Usare il category parametro per raggruppare i messaggi di output.

Questo metodo chiama il Write metodo del listener di traccia.

Vedi anche

Si applica a

Write(String)

Origine:
Debug.cs
Origine:
Debug.cs
Origine:
Debug.cs

Scrive un messaggio nei listener di traccia della raccolta 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)

Parametri

message
String

Messaggio da scrivere.

Attributi

Esempio

Nell'esempio seguente viene creato un TraceSwitch oggetto denominato generalSwitch. Questa opzione viene impostata all'esterno dell'esempio di codice.

Se l'opzione è impostata su TraceLevelError o superiore, nell'esempio viene restituito il primo messaggio di errore a Listeners. Per informazioni sull'aggiunta Listeners di un listener alla raccolta, vedere la TraceListenerCollection classe .

Se l'oggetto è impostato su Verbose, l'esempio TraceLevel restituisce il secondo messaggio di errore nella stessa riga del primo messaggio. Un terminatore di riga segue il secondo messaggio.

   // 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

Commenti

Per impostazione predefinita, l'output viene scritto in un'istanza di DefaultTraceListener.

Questo metodo chiama il Write metodo del listener di traccia.

Vedi anche

Si applica a

Write(Object)

Origine:
Debug.cs
Origine:
Debug.cs
Origine:
Debug.cs

Scrive il valore del metodo ToString() dell'oggetto nei listener di traccia nella raccolta 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)

Parametri

value
Object

Oggetto il cui nome viene inviato ai Listeners.

Attributi

Esempio

Nell'esempio seguente viene creato un TraceSwitch oggetto denominato generalSwitch. Questa opzione viene impostata all'esterno dell'esempio di codice.

Se l'opzione è impostata su TraceLevelError o superiore, nell'esempio viene restituito il primo messaggio di errore a Listeners. Per informazioni sull'aggiunta Listeners di un listener alla raccolta, vedere la TraceListenerCollection classe .

Se l'oggetto è impostato su Verbose, l'esempio TraceLevel restituisce il secondo messaggio di errore nella stessa riga del primo messaggio. Un terminatore di riga segue il secondo messaggio.

   // 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

Commenti

Per impostazione predefinita, l'output viene scritto in un'istanza di DefaultTraceListener.

Questo metodo chiama il Write metodo del listener di traccia.

Vedi anche

Si applica a