Re: Dynamically Creating Variables in C#
- From: "Abstract Dissonance" <Abstract.Dissonance@xxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 05:57:28 -0500
<ann.smithry@xxxxxxxxx> wrote in message
news:1153093771.742172.142960@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.
How would you know how to access them at compile time then?
If, say, size is a user defined input then how can you know if at runtime,
say, there will be a temp2341 or not? If you try and access it and size <
2341 then you have a compile time error... yet its at runtime.
You can make these variables at compile time if size you know how many you
want. Although it would be equivilent to manually making them.
As Leslie said, you can use arrays and this is effectively what you are
wanting to do anyways and actually makes much more sense.
.
- References:
- Dynamically Creating Variables in C#
- From: ann . smithry
- Dynamically Creating Variables in C#
- Prev by Date: Re: What language for mathematical applications?
- Next by Date: Re: Randomly outputting an array
- Previous by thread: Re: Dynamically Creating Variables in C#
- Next by thread: Extremely easy question about Time to check table look-ups
- Index(es):
Relevant Pages
|