Skip to Content
Programming Visual Basic .NET
book

Programming Visual Basic .NET

by Dave Grundgeiger
December 2001
Beginner
464 pages
13h 51m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET

Attributes

An attribute is a program element that modifies some declaration. Here is a simple example:

<SomeAttribute(  )> Public Class SomeClass
   ' ...
End Class

This example shows a fictitious SomeAttribute attribute that applies to a class declaration. Attributes appear within angle brackets (<>) and are following by parentheses (( )), which may contain a list of arguments. To apply multiple attributes to a single declaration, separate them with commas within a single set of angle brackets, like this:

<SomeAttribute(), SomeOtherAttribute(  )> Public Class SomeClass
   ' ...
End Class

Attributes can be placed on the following kinds of declarations:

Types

This includes classes, delegates, enumerations, events, interfaces, Visual Basic .NET standard modules, and structures.

The attribute is placed at the beginning of the first line of the type declaration:

<SomeAttribute(  )> Public Class SomeClass
   ' ...
End Class
Constructors

The attribute is placed at the beginning of the first line of the constructor declaration:

<SomeAttribute()> Public Sub New(  )
   ' ...
End Sub
Fields

The attribute is placed at the beginning of the field declaration:

<SomeAttribute(  )> Public SomeField As Integer
Methods

The attribute is placed at the beginning of the first line of the method declaration:

<SomeAttribute()> Public Sub SomeMethod(  )
' ...
End Sub
Parameters

The attribute is placed immediately prior to the parameter declaration. Each parameter can have its own attributes:

Public Sub SomeMethod(<SomeAttribute( )> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Visual Basic .NET, Second Edition

Programming Visual Basic .NET, Second Edition

Jesse Liberty

Publisher Resources

ISBN: 0596000936Supplemental ContentCatalog PageErrata