473,666 Members | 2,080 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.Reflecti on

Module Main

Public Sub main()
Dim b As BindingFlags = BindingFlags.No nPublic Or _
BindingFlags.Pu blic Or BindingFlags.In stance
GetProperties(G etType(foo), b)
GetProperties(G etType(foo2), b)
End Sub

Private Sub GetProperties(B yVal 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 1509
"Bob" <no****@nowhere .com> wrote in news:etKf4MCcEH A.796
@TK2MSFTNGP09.p hx.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********@rog ers.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******** *****@TK2MSFTNG P09.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
4336
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 inherited base member's access level in the derived class: its access level in the base class and the type of inheritance (public, protected, or private). After this determination is made, the following possibilities exist for manually changing the...
2
1776
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 involves creating a New instance of a derived class that inherits a base class. In C#, private member vars in the derived class ( e.g. private MySimpleObject MyObject = new MySimpleObject();) are instantiated immediately when the the calling code...
14
2626
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 Language, but there isn't a detail and complete description on all the class members, aren't they important to class composing? Could you explain the special class behavior in detail? Thank you very much.
9
6457
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 is misleading!). The complete truth is that private members are not inherited. I wish to restate the principle: "The access modifier 'private' is not just an access modifier. It also means that the member who has this modifier will not be...
0
8445
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.