473,748 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ 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(name s[0]).mem = "4";
instead of
a1.mem = "1";
Thank you,
Josh
Jul 26 '06 #1
2 950
yes, look at getmethod and invokemethod

-- bruce (sqlwork.com)
"JoshZ" <Jo***@discussi ons.microsoft.c omwrote in message
news:B1******** *************** ***********@mic rosoft.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(name s[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.getMetho d("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***@discussi ons.microsoft.c omwrote in message
news:B1******** *************** ***********@mic rosoft.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(name s[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
2310
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 in Rectangle, the compiler tells me Point::x is protected. I would have expected Rectangle to see the protected members of any Point. Compiling the following code give me this error: g++ -o rectangle main.cc main.cc: In member function `size_t...
6
2746
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 called "form1", and I have selects called "PORTA", "PORTB" ... etc...
6
2081
by: archilleswaterland | last post by:
structures typedef struct{ char name; int age; float balance; }account; account xyx; accout *ptr;
3
10926
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 flexible implementations of IComparable or Min/Max based only on FieldInfos or PropertyInfos, but I still find the fact that I have to hardcore a string with the field / property name unbearable. I re-read my post and it still seems intelligeble to...
2
2095
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 Upon inspection of _txtAmt, the old (pre-edited) value of the textbox is returned versus the changed (edited) value. Using the FindControl method should work, right? I see a lot of examples using an indexer into the e.Item.Cells.Controls to...
114
7872
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 any comments. --
1
1998
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 translate from c# if anyone can do it in that! I have created a class in my app_code folder that will access the webservice like so: Imports Microsoft.VisualBasic Imports CookComputing.XmlRpc Public Class mapserver Public Structure...
15
7869
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
1318
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 g++ -c main.cc main.cc: In function `int main()': main.cc:23: error: base operand of `->' has non-pointer type `BooleanExp' *** Error code 1 make: Fatal error: Command failed for target `main.o'
0
8984
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
9530
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
9363
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...
1
9312
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
9238
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
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
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
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
3
2206
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.