#define var var2 in c#?

#define doesn't work like that under C# by design.

It may help if you give a bit more detail about what / why you need this feature under C# as there may be a better alternative.
 
You could just declare global consts for your class if you just neede to #define some info into variables?
 
I want do it for more easy reference tu array position by example:

#define water components[5]
 
I have no knowledge of what exactly #define is, since my c++ expertise is practically non-existant. If a #define statement is made at the start of the class and not on the fly, then a property would serve your purpose (given the example you gave), if not then I can't help.
 
I have given the example
#define water components[5]

then i can initialise array :
for (int i=0;i<MAX;i++) components=x;

And then use it :
if (water > x) ...
And not:
if (components[5] > x) ...
 
Yes and as I said if water is defined at design-time then a property would suit your purpose, but not if you need to define on the fly.

C#:
public component water
{
     get { return components[5] }
}
// and then you can use
if(water > x) ...
 
The property would definately work and seems to be the closest to what you want to do. Another way of looking at it is instead of using a 5 you could make water = 5 and call the array like components[water].
 
Back
Top