Results 1 to 2 of 2

Thread: AttributeUsage

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Question AttributeUsage

    Can someone explain to me why AttributeUsage is used in a Class scenario?

    Thanks

    Code:
        <AttributeUsage(AttributeTargets.Parameter)> _
        Public Class SqlParameterAttribute
            Inherits Attribute
            Private _name As String
            Private _paramTypeDefined As Boolean
            Private _paramType As SqlDbType
            Private _size As Integer
            Private _precision As Byte
            Private _scale As Byte
            Private _directionDefined As Boolean
            Private _direction As ParameterDirection
    
            etc.............

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The Class is an Attribute, see how the name ends in Attribute and it inherits from the Attribute Class. So the AttributeUsage Attribute declares on what the attribute/class can be used on, in this case its only on parameters. That means if someone tries to apply that attribute to something other than a parameter it will give an error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width