本文整理汇总了VB.NET中System.Diagnostics.TraceSwitch.TraceSwitch构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET TraceSwitch构造函数的具体用法?VB.NET TraceSwitch怎么用?VB.NET TraceSwitch使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Diagnostics.TraceSwitch
的用法示例。
在下文中一共展示了TraceSwitch构造函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyMethod
' Class-level declaration.
' Create a TraceSwitch to use in the entire application.
Private Shared mySwitch As New TraceSwitch("General", "Entire Application")
Public Shared Sub MyMethod()
' Write the message if the TraceSwitch level is set to Error or higher.
If mySwitch.TraceError Then
Console.WriteLine("My error message.")
End If
' Write the message if the TraceSwitch level is set to Verbose.
If mySwitch.TraceVerbose Then
Console.WriteLine("My second error message.")
End If
End Sub
Public Shared Sub Main()
' Run the method that prints error messages based on the switch level.
MyMethod()
End Sub
示例2: Main
Private Shared appSwitch As new TraceSwitch("mySwitch", _
"Switch in config file")
Public Shared Sub Main(args As String())
'...
Console.WriteLine("Trace switch {0} configured as {1}",
appSwitch.DisplayName, appSwitch.Level.ToString())
If appSwitch.TraceError = True Then
'...
End If
End Sub