473,508 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not possible to get propertyinfo for inherited private members?

Bob
Is this a bug? Expected behavior? Did I get the binding flags wrong?

Bob

--------------------

Imports System.Reflection

Module Main

Public Sub main()
Dim b As BindingFlags = BindingFlags.NonPublic Or _
BindingFlags.Public Or BindingFlags.Instance
GetProperties(GetType(foo), b)
GetProperties(GetType(foo2), b)
End Sub

Private Sub GetProperties(ByVal t As Type, ByVal b As BindingFlags)
Dim str As String
For Each p As PropertyInfo In t.GetProperties(b)
str &= p.Name & vbCrLf
Next
MsgBox(str)
End Sub

End Module

Public Class foo
Private _testpublic As String
Public Property testpublic() As String
Get
Return _testpublic
End Get
Set(ByVal Value As String)
_testpublic = Value
End Set
End Property
Private _testprivate As String
Private Property testprivate() As String
Get
Return _testprivate
End Get
Set(ByVal Value As String)
_testprivate = Value
End Set
End Property
End Class

Public Class foo2
Inherits foo

End Class
Nov 20 '05 #1
2 1505
"Bob" <no****@nowhere.com> wrote in news:etKf4MCcEHA.796
@TK2MSFTNGP09.phx.gbl:
Is this a bug? Expected behavior? Did I get the binding flags wrong?


Your properties are declared as private, so you can't access them.

If you want inherited classes to be able to access "private" properties,
use Protected instead. If you need more access, you can use Friend as well.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2
Bob
Duh, naturally Private isn't accessible to inheritors. I can just use
DeclaredOnly and walk up the inheritance chain until I hit Object, Control,
or UserControl...

Bob
"Bob" <no****@nowhere.com> wrote in message
news:et*************@TK2MSFTNGP09.phx.gbl...
Is this a bug? Expected behavior? Did I get the binding flags wrong?


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4319
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
2
1769
by: twawsico | last post by:
I ran into this while converting some DX C# code to VB.NET (VS 2003), and I'm just curious as to whether this is intended behavior (and if so, where might I read up on it) or more of a bug. This...
14
2609
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
9
6442
by: ghd | last post by:
Beginners beware! Usually in lessons on inheritance, we learn that when a class extends another, the former inherits all the members of the latter. This statement is only partly true (in fact it...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.