Debug.Write Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menulis informasi tentang debug ke pendengar jejak dalam koleksi Listeners.
Overload
Write(String, String) |
Menulis nama kategori dan pesan ke pendengar pelacakan dalam koleksi Listeners. |
Write(Object, String) |
Menulis nama kategori dan nilai metode ToString() objek ke pendengar jejak dalam koleksi Listeners. |
Write(String) |
Menulis pesan ke pendengar jejak dalam koleksi Listeners. |
Write(Object) |
Menulis nilai metode ToString() objek ke pendengar jejak dalam koleksi Listeners. |
Write(String, String)
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
Menulis nama kategori dan pesan ke pendengar pelacakan dalam koleksi 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)
Parameter
- message
- String
Pesan untuk ditulis.
- category
- String
Nama kategori yang digunakan untuk mengatur output.
- Atribut
Contoh
Contoh berikut membuat TraceSwitch bernama generalSwitch
. Sakelar ini diatur di luar sampel kode.
Jika sakelar diatur ke TraceLevelError
atau lebih tinggi, contoh menghasilkan pesan kesalahan pertama ke Listeners. Untuk informasi tentang menambahkan pendengar ke koleksi Listeners, lihat kelas TraceListenerCollection.
Kemudian, jika TraceLevel diatur ke Verbose
, contoh menghasilkan pesan kesalahan kedua pada baris yang sama dengan pesan pertama. Terminator baris mengikuti pesan kedua.
// 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
Keterangan
Secara default, output ditulis ke instans DefaultTraceListener.
Gunakan parameter category
untuk mengelompokkan pesan output.
Metode ini memanggil metode Write pendengar jejak.
Lihat juga
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Berlaku untuk
Write(Object, String)
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
Menulis nama kategori dan nilai metode ToString() objek ke pendengar jejak dalam koleksi 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)
Parameter
- category
- String
Nama kategori yang digunakan untuk mengatur output.
- Atribut
Contoh
Contoh berikut membuat TraceSwitch bernama generalSwitch
. Sakelar ini diatur di luar sampel kode.
Jika sakelar diatur ke TraceLevelError
atau lebih tinggi, contoh menghasilkan pesan kesalahan pertama ke Listeners. Untuk informasi tentang menambahkan pendengar ke koleksi Listeners, lihat kelas TraceListenerCollection.
Kemudian, jika TraceLevel diatur ke Verbose
, contoh menghasilkan pesan kesalahan kedua pada baris yang sama dengan pesan pertama. Terminator baris mengikuti pesan kedua.
// 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
Keterangan
Secara default, output ditulis ke instans DefaultTraceListener.
Gunakan parameter category
untuk mengelompokkan pesan output.
Metode ini memanggil metode Write pendengar jejak.
Lihat juga
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Berlaku untuk
Write(String)
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
Menulis pesan ke pendengar jejak dalam koleksi 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)
Parameter
- message
- String
Pesan untuk ditulis.
- Atribut
Contoh
Contoh berikut membuat TraceSwitch bernama generalSwitch
. Sakelar ini diatur di luar sampel kode.
Jika sakelar diatur ke TraceLevelError
atau lebih tinggi, contoh menghasilkan pesan kesalahan pertama ke Listeners. Untuk informasi tentang menambahkan pendengar ke koleksi Listeners, lihat kelas TraceListenerCollection.
Kemudian, jika TraceLevel diatur ke Verbose
, contoh menghasilkan pesan kesalahan kedua pada baris yang sama dengan pesan pertama. Terminator baris mengikuti pesan kedua.
// 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
Keterangan
Secara default, output ditulis ke instans DefaultTraceListener.
Metode ini memanggil metode Write pendengar jejak.
Lihat juga
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Berlaku untuk
Write(Object)
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
- Sumber:
- Debug.cs
Menulis nilai metode ToString() objek ke pendengar jejak dalam koleksi 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)
Parameter
- Atribut
Contoh
Contoh berikut membuat TraceSwitch bernama generalSwitch
. Sakelar ini diatur di luar sampel kode.
Jika sakelar diatur ke TraceLevelError
atau lebih tinggi, contoh menghasilkan pesan kesalahan pertama ke Listeners. Untuk informasi tentang menambahkan pendengar ke koleksi Listeners, lihat kelas TraceListenerCollection.
Kemudian, jika TraceLevel diatur ke Verbose
, contoh menghasilkan pesan kesalahan kedua pada baris yang sama dengan pesan pertama. Terminator baris mengikuti pesan kedua.
// 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
Keterangan
Secara default, output ditulis ke instans DefaultTraceListener.
Metode ini memanggil metode Write pendengar jejak.
Lihat juga
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute