Re: Dynamically Creating Variables
- From: Tom Spink <tspink@xxxxxxxxx>
- Date: Mon, 17 Jul 2006 01:06:37 +0100
ann wrote:
Is there any way to dynamically creat variables?
In other words, I want to be able to do something like that:
for(int i=0; i<size; i++){
string temp+i = i*3;
}
I want my variables to be temp0, temp1, temp2, etc.
Hi Ann,
Why not use an array?
///
string[] temp = new string[size];
for ( int i = 0; i < size; i++ )
temp[i] = i * 3;
///
Then you can access each element with temp[0], temp[1] ... up to
temp[size-1].
--
Hope this helps,
Tom Spink
Google first, ask later.
.
- References:
- Dynamically Creating Variables
- From: ann
- Dynamically Creating Variables
- Prev by Date: Re: Dynamically Creating Variables
- Next by Date: enumerated types
- Previous by thread: Re: Dynamically Creating Variables
- Next by thread: enumerated types
- Index(es):
Relevant Pages
|