473,406 Members | 2,847 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,406 software developers and data experts.

reference an object by its name

Hi.

I have a tricky question. Suppose I have a member or local variable named
XYZ.
I want to reference the object using a string, "XYZ".

In code, I want to do the following.

Checkbox MyCheckbox = (Checkbox) doSomething("XYZ");

Is this possible in .NET? If so, how can I do it?

Thanks. Stay cool.

Nov 22 '05 #1
3 1368
Using reflection you can access uninstantiated classes, but I do not think
that you can access objects via a string. References to objects to not have
names, only the variable that holds then does. What you might try doing is
using a Hashtable which can store your object references and let you access
then via a named identifier.

"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
Hi.

I have a tricky question. Suppose I have a member or local variable named
XYZ.
I want to reference the object using a string, "XYZ".

In code, I want to do the following.

Checkbox MyCheckbox = (Checkbox) doSomething("XYZ");

Is this possible in .NET? If so, how can I do it?

Thanks. Stay cool.

Nov 22 '05 #2
Thanks. Wouldn't this be useful if it's built into a language?

"Peter Rilling" wrote:
Using reflection you can access uninstantiated classes, but I do not think
that you can access objects via a string. References to objects to not have
names, only the variable that holds then does. What you might try doing is
using a Hashtable which can store your object references and let you access
then via a named identifier.

"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
Hi.

I have a tricky question. Suppose I have a member or local variable named
XYZ.
I want to reference the object using a string, "XYZ".

In code, I want to do the following.

Checkbox MyCheckbox = (Checkbox) doSomething("XYZ");

Is this possible in .NET? If so, how can I do it?

Thanks. Stay cool.


Nov 22 '05 #3
No,

This is the difference between a program language and the scripting
language, this is always a kind of late binding what cost performance, while
there is almost no reason except that the background of the programmer is a
scripting language.

Just my thought,

Cor.
Nov 22 '05 #4

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

Similar topics

5
by: Javier Campos | last post by:
WARNING: This is an HTML post, for the sake of readability, if your client can see HTML posts, do it, it doesn't contain any script or virus :-) I can reformat a non-HTML post if you want me to (and...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
18
by: man | last post by:
can any one please tell me what is the diff between pointer and reference.....and which one is better to use ....and why???????
5
by: Mike Logan | last post by:
I used WSDL.exe to generate a client side web proxy for a web service, called the web service, got the results but an array returned by the web service is not in the results. However if I use...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
0
by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
10
by: Arpan | last post by:
Consider the following code that adds a table to a DataSet dynamically: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) 'Create an empty DataSet Dim dSet As...
12
by: John Henry | last post by:
Hi list, Just to make sure I understand this. Since there is no "pointer" type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...

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.