Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Knowing if a property exists
Message
From
03/03/2011 11:45:59
 
 
To
03/03/2011 09:05:30
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01502282
Message ID:
01502518
Views:
39
>>Does the property have a public accessor. Docs:
>>"A property is considered public to reflection if it has at least one accessor that is public." For clarity if should read:
>>"A property is only considered public to reflection if it has at least one accessor that is public."
>>For the following class GetProperties() would only return PropertyA, GetMembers() would return PropertyA and PropertyB:
Public Class SomeClass
>>    Public PropertyB As String
>>    Dim _propertyA As String
>>    Public Property PropertyA As String
>>        Get
>>            Return _propertyA
>>        End Get
>>        Set(ByVal value As String)
>>            _propertyA = value
>>        End Set
>>    End Property
>>End Class
>
>Thanks, that is what I started to suspect last night.
>
>Would there be a way to verify for PropertyB, in your example, and get its value if it exists?

Looks like you've got it - but just to throw in some Linq :-} :
Dim mi As System.Reflection.MemberInfo = (From xx In oLabel.GetType().GetMembers() _
                                                  Where xx.Name = "PropertyB" Select xx).FirstOrDefault()

        If Not mi Is Nothing Then
            'Got it
        End If
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform