473,387 Members | 1,394 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,387 software developers and data experts.

about variable

Jie
Hi ,everyOne:
i has a question, please help me.

string strBB = "Hello World!";
string strAA = "strBB"
how can i just know about strAA's value, to get the strbb's Value????
like the controls can use findControls("objName")!

Please Help me!
Aug 18 '06 #1
4 1051
Jie,
This does not make sense. You are setting string strAA to a literal string
of "strBB".
if you set strAA to strBB (e.g., string strAA = strBB ) then you have two
completely separate strings strAA and strBB, both with the value "Hello
World". Strings are immutable. What's the goal here?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jie" wrote:
Hi ,everyOne:
i has a question, please help me.

string strBB = "Hello World!";
string strAA = "strBB"
how can i just know about strAA's value, to get the strbb's Value????
like the controls can use findControls("objName")!

Please Help me!
Aug 18 '06 #2
You can start down this road:

This was a (from)C# translation, but I don't have the C# with me at the
moment.
Private Function MatchPropertyNonString(ByVal obj As Object, ByVal
propertyName As String, ByVal value As Object) As Boolean
Dim match As Boolean = False
Dim propertyInfo As propertyInfo =
obj.GetType.GetProperty(propertyName)
If (Not (propertyInfo) Is Nothing) Then
Try
Dim target As Object = propertyInfo.GetValue(obj, Nothing)

'Now return whether the property matches or not
'Notice the equals takes any object type as a parameter
match = target.Equals(value)

Return match

Catch ex As Exception
Dim e As String = ex.Message
End Try
End If
Return match
End Function

Strings are trickier, because you may want to trim them, or use or not use
case sensitivity.


"Jie" <wj***@21cn.comwrote in message
news:eo*************@TK2MSFTNGP02.phx.gbl...
Hi ,everyOne:
i has a question, please help me.

string strBB = "Hello World!";
string strAA = "strBB"
how can i just know about strAA's value, to get the strbb's Value????
like the controls can use findControls("objName")!

Please Help me!


Aug 18 '06 #3
sloan wrote:
You can start down this road:
[evil reflection stuff]
Gah. Now he's actually going to use that in a program.

Eq.
Aug 18 '06 #4
[evil reflection stuff]
Gah. Now he's actually going to use that in a program.
Agreed; almost /any/ other soltion would be preferable... alternatives;
my preference between a and b would depend on the number of "variables"
to track; if low, a; if high b. The third (c) is just an "a.n.other"
option.

a: a switch block that considers a number of known names
b: a property bag - for instance a Dictionary<string,stringthat you
could use to say someValues["nameA"]="valueB";
and
string value = someValues["nameA"];
c: databinding directly to a UI by property (not field or variable)
name; still reflection under the bonnet, but less chances to get it
wrong
d: anything

Or suchlike.

Marc

Aug 18 '06 #5

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

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
11
by: kazack | last post by:
I am under the the impression that a variable is what is stored in a memory address and a pointer is the memory address of the variable? I was looking to use a function that does not return a...
3
by: Joe C | last post by:
I have some code that performs bitwise operations on files. I'm trying to make the code portable on different endian systems. This is not work/school related...just trying to learn/understand. ...
17
by: kj | last post by:
How can one test if a pointer has been "freed" (i.e. with free())? My naive assumption was that such a pointer would equal NULL, but not so. Thanks, kj -- NOTE: In my address everything...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
9
by: JoeC | last post by:
I am trying to create a simple maze program on a window. I am trying to create a global var to handle the commands. I declare: #include "space.h" #include "player.h" #include "Command.h" ...
30
by: questions? | last post by:
say I have a structure which have an array inside. e.g. struct random_struct{ char name; int month; } if the array is not intialized by me, in a sense after I allocated a
13
by: yanlinlin82 | last post by:
I'd like to write all code of a class in only header file. But when there is any static member varia ble, I have to define it in cpp file, not the header file. Otherwise, the static member variable...
23
by: Tony Johansson | last post by:
Hello! I just wonder what is the point of having the reader variable declared as TextReader in the snippet below.. Is it because of using the polymorfism on the reader variable perhaps. using...
15
by: SM | last post by:
Hello, I have another simple question about an array in PHP and a variable in PHP. This is the array: $thumbs_cat_1 = array( 'wine', 'cheese', 'ice',
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.