Results 1 to 3 of 3

Thread: Custom Attributes

  1. #1

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    Exclamation Custom Attributes

    Hi everybody,
    Can anybody explain me about Custom Attributes and how are they implemented?. I mean what is the significance of using separate class for Attributes?
    Thanks in advance,
    abhid

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What do you mean by Custom Attributes? Like Serializeable?

  3. #3

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    Originally posted by Edneeis
    What do you mean by Custom Attributes? Like Serializeable?
    no, I am referring to Attribute class in .Net
    Actually I have a huge code where I have some classes with tags like
    VB Code:
    1. Imports System.Reflection
    2. Public Class clsUserScreen
    3.  
    4. <clsMyProperty(prp_UserName:="ABC", prp_Age:="40")> Public Property prp_User1() As String 'I want to Know working of this part
    5. ...
    6. End Property
    7. ...
    8. End Class
    and clsMyProperty class is defined like
    VB Code:
    1. <AttributeUsage(AttributeTargets.All, inherited:=True, AllowMultiple:=False)> Public Class clsMyProperty
    2.     Inherits Attribute 'This class is member of System
    3.  
    4. #Region "Member Variables"
    5.     Private strUserName As String
    6.     Private strAge As String
    7. #End Region
    8.  
    9. #Region "Class Propertis"
    10.     Public Property prp_UserName() As String
    11.         Get
    12.             Return strUserName
    13.         End Get
    14.         Set(ByVal strValue As String)
    15.             strUserName = strValue
    16.         End Set
    17.     End Property
    18.     Public Property prp_Age() As String
    19.         Get
    20.             Return strAge
    21.         End Get
    22.         Set(ByVal strValue As String)
    23.             strAge = strValue
    24.         End Set
    25.     End Property
    26. #End Region
    27.  
    28. End Class
    This is just a small example though. I have huge list of classes using custom attributes and I need to write some code based upon these classes. But first I want to understand this code fully although I will not be referring to these attributes in MY code.
    I read in MSDN regarding Attribute class but I want to know what is exact significance of using custom attributes for a class property.

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