473,469 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessing member using literal name

Is it possible if i have
class x {
object a1;
object b2;
object c3;
string names[] = {"a1", "b2", "c3"};
}
to iterate through the class members via Reflection or some other sort of
the current class, not just an instance of the class and acess these members
and manipulate their properties using their literal names i.e.
someMagicMethod.getMember(names[0]).mem = "4";
instead of
a1.mem = "1";
Thank you,
Josh
Jul 26 '06 #1
2 936
yes, look at getmethod and invokemethod

-- bruce (sqlwork.com)
"JoshZ" <Jo***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
Is it possible if i have
class x {
object a1;
object b2;
object c3;
string names[] = {"a1", "b2", "c3"};
}
to iterate through the class members via Reflection or some other sort of
the current class, not just an instance of the class and acess these
members
and manipulate their properties using their literal names i.e.
someMagicMethod.getMember(names[0]).mem = "4";
instead of
a1.mem = "1";
Thank you,
Josh

Jul 26 '06 #2
Yes, I've already looked at that:
Type myType = typeof(MyClass);
MemberInfo myMemInfo = myType.getMethod("MyFunc",
...etc.

Which gets me a method and I could create method accessors for all the
object I want, but the problem is that it is still not able to get the
current instance that I'm actually working in.

"bruce barker (sqlwork.com)" wrote:
yes, look at getmethod and invokemethod

-- bruce (sqlwork.com)
"JoshZ" <Jo***@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
Is it possible if i have
class x {
object a1;
object b2;
object c3;
string names[] = {"a1", "b2", "c3"};
}
to iterate through the class members via Reflection or some other sort of
the current class, not just an instance of the class and acess these
members
and manipulate their properties using their literal names i.e.
someMagicMethod.getMember(names[0]).mem = "4";
instead of
a1.mem = "1";
Thank you,
Josh


Jul 26 '06 #3

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

Similar topics

2
by: Steven T. Hatton | last post by:
I find the surprising. If I derive Rectangle from Point, I can access the members of Point inherited by Rectangle _IF_ they are actually members of a Rectangle. If I have a member of type Point...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
6
by: archilleswaterland | last post by:
structures typedef struct{ char name; int age; float balance; }account; account xyx; accout *ptr;
3
by: Ken Durden | last post by:
Hey, I posted this a few months ago and got completely off-the-chart responses. At the time I wasn't using reflection very much, but more and more I find myself wanting to use it to write...
2
by: EddieG | last post by:
I am having a problem accessing changed values in TextBoxes returned via the OnUpdaterow event. Using C# I access the control using: string _txtAmt = ((TextBox)e.Item.FindControl("txtAmount")).Text ...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
1
by: carled | last post by:
Hi all. New here and new to .net from classic asp. I have to access an xml-rpc webservice in .net and it's making my brain fry trying to get it all set up. I'm most comfortable with vb, but I can...
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
3
by: Tex08 | last post by:
Again, I am trying to implement a composite pattern to handle a binary expression. Compiling with g++ (required), I receive the following error trying to access data in a derived class: make...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
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...
0
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
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 ...

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.