Debug.Write Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Zapisuje informacje o debugowaniu do odbiorników śledzenia w kolekcji Listeners .
Przeciążenia
Write(String, String) |
Zapisuje nazwę kategorii i komunikat do odbiorników śledzenia w kolekcji Listeners . |
Write(Object, String) |
Zapisuje nazwę kategorii i wartość metody obiektu ToString() do odbiorników śledzenia w kolekcji Listeners . |
Write(String) |
Zapisuje komunikat do odbiorników śledzenia w kolekcji Listeners . |
Write(Object) |
Zapisuje wartość metody obiektu ToString() do odbiorników śledzenia w kolekcji Listeners . |
Write(String, String)
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
Zapisuje nazwę kategorii i komunikat do odbiorników śledzenia w kolekcji 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)
Parametry
- message
- String
Komunikat do zapisu.
- category
- String
Nazwa kategorii, używana do organizowania danych wyjściowych.
- Atrybuty
Przykłady
W poniższym przykładzie zostanie utworzona nazwana TraceSwitchgeneralSwitch
. Ten przełącznik jest ustawiony poza przykładem kodu.
Jeśli przełącznik jest ustawiony na TraceLevelError
lub wyższy, przykład zwraca pierwszy komunikat o błędzie do .Listeners Aby uzyskać informacje na temat dodawania odbiornika do Listeners kolekcji, zobacz klasę TraceListenerCollection .
Następnie, jeśli TraceLevel parametr ma wartość Verbose
, przykład generuje drugi komunikat o błędzie w tym samym wierszu co pierwszy komunikat. Terminator wiersza jest zgodny z drugim komunikatem.
// 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
Uwagi
Domyślnie dane wyjściowe są zapisywane w wystąpieniu klasy DefaultTraceListener.
Użyj parametru do category
grupowania komunikatów wyjściowych.
Ta metoda wywołuje metodę Write odbiornika śledzenia.
Zobacz też
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Dotyczy
Write(Object, String)
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
Zapisuje nazwę kategorii i wartość metody obiektu ToString() do odbiorników śledzenia w kolekcji 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)
Parametry
- category
- String
Nazwa kategorii, używana do organizowania danych wyjściowych.
- Atrybuty
Przykłady
W poniższym przykładzie zostanie utworzona nazwana TraceSwitchgeneralSwitch
. Ten przełącznik jest ustawiony poza przykładem kodu.
Jeśli przełącznik jest ustawiony na TraceLevelError
lub wyższy, przykład zwraca pierwszy komunikat o błędzie do .Listeners Aby uzyskać informacje na temat dodawania odbiornika do Listeners kolekcji, zobacz klasę TraceListenerCollection .
Następnie, jeśli TraceLevel parametr ma wartość Verbose
, przykład generuje drugi komunikat o błędzie w tym samym wierszu co pierwszy komunikat. Terminator wiersza jest zgodny z drugim komunikatem.
// 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
Uwagi
Domyślnie dane wyjściowe są zapisywane w wystąpieniu klasy DefaultTraceListener.
Użyj parametru do category
grupowania komunikatów wyjściowych.
Ta metoda wywołuje metodę Write odbiornika śledzenia.
Zobacz też
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Dotyczy
Write(String)
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
Zapisuje komunikat do odbiorników śledzenia w kolekcji 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)
Parametry
- message
- String
Komunikat do zapisu.
- Atrybuty
Przykłady
W poniższym przykładzie zostanie utworzona nazwana TraceSwitchgeneralSwitch
. Ten przełącznik jest ustawiony poza przykładem kodu.
Jeśli przełącznik jest ustawiony na TraceLevelError
lub wyższy, przykład zwraca pierwszy komunikat o błędzie do .Listeners Aby uzyskać informacje na temat dodawania odbiornika do Listeners kolekcji, zobacz klasę TraceListenerCollection .
Następnie, jeśli TraceLevel parametr ma wartość Verbose
, przykład generuje drugi komunikat o błędzie w tym samym wierszu co pierwszy komunikat. Terminator wiersza jest zgodny z drugim komunikatem.
// 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
Uwagi
Domyślnie dane wyjściowe są zapisywane w wystąpieniu klasy DefaultTraceListener.
Ta metoda wywołuje metodę Write odbiornika śledzenia.
Zobacz też
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Dotyczy
Write(Object)
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
- Źródło:
- Debug.cs
Zapisuje wartość metody obiektu ToString() do odbiorników śledzenia w kolekcji 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)
Parametry
- Atrybuty
Przykłady
W poniższym przykładzie zostanie utworzona nazwana TraceSwitchgeneralSwitch
. Ten przełącznik jest ustawiony poza przykładem kodu.
Jeśli przełącznik jest ustawiony na TraceLevelError
lub wyższy, przykład zwraca pierwszy komunikat o błędzie do .Listeners Aby uzyskać informacje na temat dodawania odbiornika do Listeners kolekcji, zobacz klasę TraceListenerCollection .
Następnie, jeśli TraceLevel parametr ma wartość Verbose
, przykład generuje drugi komunikat o błędzie w tym samym wierszu co pierwszy komunikat. Terminator wiersza jest zgodny z drugim komunikatem.
// 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
Uwagi
Domyślnie dane wyjściowe są zapisywane w wystąpieniu klasy DefaultTraceListener.
Ta metoda wywołuje metodę Write odbiornika śledzenia.
Zobacz też
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla