给定以下类,我如何从 SampleAttribute 中截取 Class1.SampleMethod 的值?谢谢
Public Class Class1
<SampleAttribute()> _
Public Function SampleMethod(ByVal Value As Integer) As Boolean
Return True
End Function
End Class
<AttributeUsage(AttributeTargets.Method)> _
Public Class SampleAttribute
Inherits System.Attribute
Private _Value As Integer
Property Value() As Integer
Get
Return _Value
End Get
Set(ByVal value As Integer)
_Value = value
End Set
End Property
Public Sub New()
End Sub
End Class
编辑:
鉴于 Andrew Hare 的回答,也许我正在尝试使用错误的构造。我有一长串类似的方法,每次调用其中一个时我都需要执行一组操作。我认为为它们中的每一个附加一个属性将是最直接的解决方案。有什么建议吗?