本文整理汇总了VB.NET中System.ObsoleteAttribute类的典型用法代码示例。如果您正苦于以下问题:VB.NET ObsoleteAttribute类的具体用法?VB.NET ObsoleteAttribute怎么用?VB.NET ObsoleteAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObsoleteAttribute类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Reflection
Public Module Example
' Mark OldProperty As Obsolete.
<ObsoleteAttribute("This property is obsolete. Use NewProperty instead.", False)>
Public ReadOnly Property OldProperty As String
Get
Return "The old property value."
End Get
End Property
Public ReadOnly Property NewProperty As String
Get
Return "The new property value."
End Get
End Property
' Mark OldMethod As Obsolete.
<ObsoleteAttribute("This method is obsolete. Call CallNewMethod instead.", True)>
Public Function CallOldMethod() As String
Return "You have called CallOldMethod."
End Function
Public Function CallNewMethod() As String
Return "You have called NewMethod."
End Function
Public Sub Main()
Console.WriteLine(OldProperty)
Console.WriteLine()
Console.WriteLine(CallOldMethod())
End Sub
End Module
' The attempt to compile this example produces output like the following:
' Example.vb(30) : warning BC40000: 'Public ReadOnly Property OldProperty As String' is obsolete:
' 'This property is obsolete. Use NewProperty instead.'.
'
' Console.WriteLine(OldProperty)
' ~~~~~~~~~~~
' Example.vb(32) : error BC30668: 'Public Function CallOldMethod() As String' is obsolete:
' 'This method is obsolete. Call CallNewMethod instead.'.
'
' Console.WriteLine(CallOldMethod())
' ~~~~~~~~~~~~~