O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Custom Attributes and Recognizing Them at Runtime

Next to manual data serialization, recognizing and reacting to custom attributes at runtime is probably the most frequent way of using reflection techniques. As mentioned earlier, attributes serve to mark classes or class elements. Attribute classes normally don’t have any real functionality, because only very rarely is their class code executed.

Companion Content

Open the corresponding solution (.sln), which you can find in the \VB 2010 Developer Handbook\Chapter 21\Reflection02 folder.

The code file mdlMain.vb contains the definition of an Attribute class, which appears as follows:

'Create custom attribute
<AttributeUsage(AttributeTargets.All)>
Public Class MyAttribute
    Inherits Attribute ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required