473,786 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get field info of base class with reflection

Hi,

I have a class that exist in my UI assembly that inherits from a class
in a referenced assembly like this.

class EmployeesDC
{
private string mstrEmployeeNum ber;

etc
}

class EmployeesBL : EmployeesDC
{
}

Then in UI Assembly

class Employees : EmployeesBL
{
}

Can someone give me the code so I can get info on the private fields
in EmployeesDC using reflection.

I have googled but I am still not clear how??

thanks
rotsey


Jun 22 '07
10 9467
OK thanks for your input.

This is my whoe class in the UI assembly

public class Employees : EmployeesBL, ILoadableData, ILookUpObject

{

public Employees()

{

ConnectString = TBRSettings.Ins tance.Settings. ConnectionStrin g;

}

public Employees(strin g connString)

{

ConnectString = connString;

}

public DataSet GetRowFromID(in t ID)

{

return GetEmployee(ID) ;

}

public string GetFieldtype(st ring fieldname)

{

Type t = this.GetType();

BindingFlags bf = BindingFlags.De fault;

bf |= BindingFlags.No nPublic;

bf |= BindingFlags.Fl attenHierarchy;

bf |= BindingFlags.In stance;

foreach (FieldInfo field in t..GetFields(bf ))

{

if (field.Name.End sWith(fieldname ))

return field.Name.Subs tring(0, 4);

}

return "";

}

}

"Tom Spink" <ts****@gmail.c omwrote in message
news:eA******** ********@TK2MSF TNGP06.phx.gbl. ..
Rotsey wrote:
>you gave up on me Tom.

I had to reference the base class directly to get the private fields.

Don't know why your method doesn't work?
<snippedy-doo-dah>
>you gave up on me Tom.

I may be a student, but I have a job ;-)
>I had to reference the base class directly to get the private fields.

Don't know why your method doesn't work?

Can you post the code you were using?

--
Tom Spink
University of Edinburgh

Jun 23 '07 #11

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

Similar topics

1
2660
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of the property in the derived class, and I can use the derived class as expected through standard instantiation. The unexpected behavior occurs when I try to set gather the PropertyInfo for the derived class property via Reflection. I get an...
8
1491
by: Lars-Erik Aabech | last post by:
Hi! I've been looking around for an attribute that tells the intellitip thingy to skip some field or operation. Is there any? IE. a ListControl object has the DataSource property, but not all of the inherited classes "supports" that public property, although you can use them. Some of these properties are hidden from intellitip, but doesn't throw a compiler error. Ex.:
8
2035
by: Calan | last post by:
I have a server-side ASP script that dynamically creates an input form from a database table. The table contains a field name, the table where values are stored, type of input control, value for a label, etc. What I need to do is create a JS validation routine that will check each control for valid input, regardless of what the control name is. If it is a "select", it needs to verify the index is > 1. If it is an "input", it needs to...
10
7372
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a Windows.Forms.UserControl in a COM environment, i.e. I want to host that control in a COM host. So far, so good, I can host it, but I can not reach the parent COM object from the control (Parent property is null :( ). I have stopped the control in the...
3
2534
by: tony lock | last post by:
I am writing a simulation program, the main classes inherit from a base class which itself inherits from Control. I am using reflection to serialize these objects including the fields from control. This works perfectly apart from the field text in Control which always comes back null. Although the IDE always shows it having the correct value. Since the IDE presumably uses reflection to show the value, I am at a loss to know why this one...
10
25743
by: Abelardo Vacca | last post by:
Hi, The title sums up the question pretty much. I would like to access all private members of a class including the private members of its base classes.( I already have the ReflectionPermission ) Is there a way to get this information ? Thnaks in advance
5
3164
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits CommonPageBase - Contains myPage which inherits PageBase Each of these classes overrides OnInit and ties an event handler
6
2147
by: Philip Warner | last post by:
I have a set of classes: C (base) C1 (inherits C) C2 (inherits C) ... Cn (inherits C) (the C1..Cn also have subclasses, but thats not really relevant to the question)
26
5375
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is because I am not always able to control/create all the different constructors the base class has. My problem can be described in code as follows ... /* This is the base class with a whole heap of constructors/functionality*/ public class Animal
0
9647
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...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
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
7510
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
6744
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
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
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 we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.