PDA

Click to See Complete Forum and Search --> : Custom Attributes


abhid
Nov 7th, 2002, 12:28 AM
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

Edneeis
Nov 7th, 2002, 02:26 AM
What do you mean by Custom Attributes? Like Serializeable?

abhid
Nov 7th, 2002, 04:35 AM
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

Imports System.Reflection
Public Class clsUserScreen

<clsMyProperty(prp_UserName:="ABC", prp_Age:="40")> Public Property prp_User1() As String 'I want to Know working of this part
...
End Property
...
End Class

and clsMyProperty class is defined like

<AttributeUsage(AttributeTargets.All, inherited:=True, AllowMultiple:=False)> Public Class clsMyProperty
Inherits Attribute 'This class is member of System

#Region "Member Variables"
Private strUserName As String
Private strAge As String
#End Region

#Region "Class Propertis"
Public Property prp_UserName() As String
Get
Return strUserName
End Get
Set(ByVal strValue As String)
strUserName = strValue
End Set
End Property
Public Property prp_Age() As String
Get
Return strAge
End Get
Set(ByVal strValue As String)
strAge = strValue
End Set
End Property
#End Region

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.