473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Indirection Question

I'm writing a C# class and need to do something known to me in Cache (another
language) as indirection. Not sure if the functionality exists in C#, but
could really use some help here. Basically, pretend a method takes in two
string variables: field (and we'll say the value is Name) and fieldvalue (and
we'll say the value is Chris). This is within a public class having a field
of Name. I need that variable to now be set to Chris. Any ideas how I can
accompilsh this without a switch or if/else?
Oct 25 '08 #1
2 2897
It sounds to me like "reflection". Have a look at this link and see if it
gets you started: http://msdn.microsoft.com/en-us/library/53seyfee.aspx.
"cmitroka" <cm******@discussions.microsoft.comwrote in message
news:9D**********************************@microsof t.com...
I'm writing a C# class and need to do something known to me in Cache
(another
language) as indirection. Not sure if the functionality exists in C#, but
could really use some help here. Basically, pretend a method takes in two
string variables: field (and we'll say the value is Name) and fieldvalue
(and
we'll say the value is Chris). This is within a public class having a
field
of Name. I need that variable to now be set to Chris. Any ideas how I
can
accompilsh this without a switch or if/else?
Oct 25 '08 #2
On Oct 25, 5:24 pm, cmitroka <cmitr...@discussions.microsoft.com>
wrote:
I'm writing a C# class and need to do something known to me in Cache (another
language) as indirection. Not sure if the functionality exists in C#, but
could really use some help here. Basically, pretend a method takes in two
string variables: field (and we'll say the value is Name) and fieldvalue (and
we'll say the value is Chris). This is within a public class having a field
of Name. I need that variable to now be set to Chris. Any ideas how I can
accompilsh this without a switch or if/else?
Hi,

Take a look at Reflection,
method(string propName, strnig Value){
this.GetType().InvokeMember(propName,
System.Reflection.BindingFlags.SetProperty, null, new object[]
{ propValue });
}
Oct 27 '08 #3

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

Similar topics

5
by: Nobody | last post by:
excuse the "windows" code below, but this is a C++ question... or maybe a C. Anyways, I want a function where I can pass in an array of strings (variable count, variable size), so I defined this:...
15
by: Matthias Kaeppler | last post by:
Hi, as a result of my last posting about an adaption class template for invoking algorithms on a container of iterators or pointers to elements in another container, I have come up with this...
10
by: blimeyoreilly | last post by:
Hi I've a small problem .. can anyone figure it out? I am working in VS.NET in C++ with MFC. I have a CWinApp-based class called CTestHarnessApp. I keep getting the 'differs in levels of...
7
by: Holger Grund | last post by:
What's special about System::String? For instance, why can't one write a function like using System::String; void foo( const String% ); or what's wrong with: int main() {
19
by: santosh | last post by:
Hi all, In the following program I allocate a block of pointers to type char, initialised to zero. I then point each of those pointers to a block of allocated memory of fixed size (33 bytes). A...
6
by: Angus | last post by:
I am using a global which is a void* I have it defined in one file as: void* hFlag; and one other header file as: extern void* hFlag; But I get this compile error:
9
by: william | last post by:
When implementing Linked list, stack, or trees, we always use pointers to 'link' the nodes. And every node is always defined as: struct node { type data; //data this node contains ... node *...
3
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
1
Markus
by: Markus | last post by:
I'm having a hard time grasping the concept of multiple levels of indirection, that is for example a char **. I understand that passing a pointer to some data to a function means that memory for that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.