本文整理汇总了VB.NET中System.Diagnostics.ConditionalAttribute类的典型用法代码示例。如果您正苦于以下问题:VB.NET ConditionalAttribute类的具体用法?VB.NET ConditionalAttribute怎么用?VB.NET ConditionalAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConditionalAttribute类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Test
#Const CONDITION1 = True
#Const CONDITION2 = True
Imports System.Diagnostics
Class Test
Shared Sub Main()
Console.WriteLine("Calling Method1")
Method1(3)
Console.WriteLine("Calling Method2")
Method2()
Console.WriteLine("Using the Debug class")
Debug.Listeners.Add(New ConsoleTraceListener())
Debug.WriteLine("DEBUG is defined")
End Sub
<ConditionalAttribute("CONDITION1")> _
Shared Sub Method1(x As Integer)
Console.WriteLine("CONDITION1 is defined")
End Sub
<ConditionalAttribute("CONDITION1"), ConditionalAttribute("CONDITION2")> _
Shared Sub Method2()
Console.WriteLine("CONDITION1 or CONDITIOIN2 is defined")
End Sub
End Class
' When compiled as shown, the application (named ConsoleApp)
输出:
Calling Method1 CONDITION1 is defined Calling Method2 CONDITION1 or CONDITION2 is defined Using the Debug class DEBUG is defined