Attribute Reference
Attributes are metadata you can apply to program elements (classes, methods, properties, etc.) to provide additional information to the compiler or runtime.
Attribute | Target | Description | Example |
---|---|---|---|
Serializable |
Class, Structure | Indicates that a type can be serialized. |
|
Obsolete |
Any | Marks program elements that should no longer be used. |
|
DebuggerStepThrough |
Method, Property, Constructor | Instructs the debugger to step through the code without stopping. |
|
DllImport |
Method | Declares an external method implemented in an unmanaged DLL. |
|
CLSCompliant |
Assembly, Module, Type, Member | Indicates whether the code follows the Common Language Specification. |
|
Using Custom Attributes
You can define your own attribute by inheriting from Attribute
.
Public Class DocumentationAttribute
Inherits Attribute
Public ReadOnly Property Url As String
Public Sub New(url As String)
Me.Url = url
End Sub
End Class
<Documentation("https://example.com/api")>
Public Class ApiClient
'...
End Class