Debug.Write Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Hata ayıklama hakkındaki bilgileri koleksiyondaki Listeners izleme dinleyicilerine yazar.
Aşırı Yüklemeler
Write(String, String) |
Koleksiyondaki Listeners izleme dinleyicilerine bir kategori adı ve ileti yazar. |
Write(Object, String) |
Koleksiyondaki izleme dinleyicilerine bir kategori adı ve nesnenin ToString() yönteminin Listeners değerini yazar. |
Write(String) |
Koleksiyondaki izleme dinleyicilerine Listeners bir ileti yazar. |
Write(Object) |
Nesnesinin ToString() yönteminin değerini koleksiyondaki Listeners izleme dinleyicilerine yazar. |
Write(String, String)
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
Koleksiyondaki Listeners izleme dinleyicilerine bir kategori adı ve ileti yazar.
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)
Parametreler
- message
- String
Yazılacak ileti.
- category
- String
Çıkışı düzenlemek için kullanılan kategori adı.
- Öznitelikler
Örnekler
Aşağıdaki örnek adlı generalSwitch
bir TraceSwitch oluşturur. Bu anahtar kod örneğinin dışında ayarlanır.
Anahtar veya daha yüksek bir değere TraceLevelError
ayarlanırsa, örnek ilk hata iletisini olarak Listenersdöndürür. Koleksiyona dinleyici ekleme hakkında bilgi için Listeners sınıfına TraceListenerCollection bakın.
Daha sonra , olarak ayarlanırsa TraceLevelVerbose
, örnek ilk iletiyle aynı satırda ikinci hata iletisinin çıkışını alır. İkinci iletiyi izleyen bir satır sonlandırıcısı.
// 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
Açıklamalar
Varsayılan olarak, çıktı bir örneğine DefaultTraceListeneryazılır.
category
Çıkış iletilerini gruplandırmak için parametresini kullanın.
Bu yöntem, izleme dinleyicisinin yöntemini çağırır Write .
Ayrıca bkz.
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Şunlara uygulanır
Write(Object, String)
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
Koleksiyondaki izleme dinleyicilerine bir kategori adı ve nesnenin ToString() yönteminin Listeners değerini yazar.
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)
Parametreler
- category
- String
Çıkışı düzenlemek için kullanılan kategori adı.
- Öznitelikler
Örnekler
Aşağıdaki örnek adlı generalSwitch
bir TraceSwitch oluşturur. Bu anahtar kod örneğinin dışında ayarlanır.
Anahtar veya daha yüksek bir değere TraceLevelError
ayarlanırsa, örnek ilk hata iletisini olarak Listenersdöndürür. Koleksiyona dinleyici ekleme hakkında bilgi için Listeners sınıfına TraceListenerCollection bakın.
Daha sonra , olarak ayarlanırsa TraceLevelVerbose
, örnek ilk iletiyle aynı satırda ikinci hata iletisinin çıkışını alır. İkinci iletiyi izleyen bir satır sonlandırıcısı.
// 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
Açıklamalar
Varsayılan olarak, çıktı bir örneğine DefaultTraceListeneryazılır.
category
Çıkış iletilerini gruplandırmak için parametresini kullanın.
Bu yöntem, izleme dinleyicisinin yöntemini çağırır Write .
Ayrıca bkz.
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Şunlara uygulanır
Write(String)
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
Koleksiyondaki izleme dinleyicilerine Listeners bir ileti yazar.
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)
Parametreler
- message
- String
Yazılacak ileti.
- Öznitelikler
Örnekler
Aşağıdaki örnek adlı generalSwitch
bir TraceSwitch oluşturur. Bu anahtar kod örneğinin dışında ayarlanır.
Anahtar veya daha yüksek bir değere TraceLevelError
ayarlanırsa, örnek ilk hata iletisini olarak Listenersdöndürür. Koleksiyona dinleyici ekleme hakkında bilgi için Listeners sınıfına TraceListenerCollection bakın.
Daha sonra , olarak ayarlanırsa TraceLevelVerbose
, örnek ilk iletiyle aynı satırda ikinci hata iletisinin çıkışını alır. İkinci iletiyi izleyen bir satır sonlandırıcısı.
// 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
Açıklamalar
Varsayılan olarak, çıktı bir örneğine DefaultTraceListeneryazılır.
Bu yöntem, izleme dinleyicisinin yöntemini çağırır Write .
Ayrıca bkz.
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Şunlara uygulanır
Write(Object)
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
- Kaynak:
- Debug.cs
Nesnesinin ToString() yönteminin değerini koleksiyondaki Listeners izleme dinleyicilerine yazar.
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)
Parametreler
- Öznitelikler
Örnekler
Aşağıdaki örnek adlı generalSwitch
bir TraceSwitch oluşturur. Bu anahtar kod örneğinin dışında ayarlanır.
Anahtar veya daha yüksek bir değere TraceLevelError
ayarlanırsa, örnek ilk hata iletisini olarak Listenersdöndürür. Koleksiyona dinleyici ekleme hakkında bilgi için Listeners sınıfına TraceListenerCollection bakın.
Daha sonra , olarak ayarlanırsa TraceLevelVerbose
, örnek ilk iletiyle aynı satırda ikinci hata iletisinin çıkışını alır. İkinci iletiyi izleyen bir satır sonlandırıcısı.
// 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
Açıklamalar
Varsayılan olarak, çıktı bir örneğine DefaultTraceListeneryazılır.
Bu yöntem, izleme dinleyicisinin yöntemini çağırır Write .
Ayrıca bkz.
- Debug
- Trace
- BooleanSwitch
- TraceSwitch
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- ConditionalAttribute
Şunlara uygulanır
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin