- Joined
- Jan 17, 2010
- Messages
- 6,110
Is it possible in C# to use textmacros like in vjass code?
For example, I want to send an integer into function.
And then that function use this argument in object names within it.
EDIT:
I need to solve next problem:
Original code is like 20 times larger that this here.
Everything is working fine, I just need to know is they any way around.
Because all I need is to send this simple integer (call it ID) that will then edit all those objects:
button_x_$ID$
button_y_$ID$
label_x_$ID$
label_y_$ID$
Only way I see here, as some sort of solution, is to make array:
B_X[1] = button_x_1;
B_X[2] = button_x_2;
B_X[3] = button_x_3;
B_Y[1] = button_y_1;
B_Y[2] = button_y_2;
B_Y[3] = button_y_3;
etc
But that create other problems like static and non static class members, I need to create huge lists of those array initialization and so on.
For example, I want to send an integer into function.
And then that function use this argument in object names within it.
Code:
some_function(string text)
{
$text$.Text = "something like this";
variable_$text$ = 1; // + this
variable[$text$] = whatever; // and/or even something like this...
}
EDIT:
I need to solve next problem:
Code:
func(Button b1, Button b2, Label l1, Label l2)
{
b1.Text = "some text 1";
b1.Text = "some text 1";
l1.Text = "some text 2";
l2.Text = "some text 2";
//...
}
//some code
//...
func(button_x_1, button_y_1, label_x_1, label_y_1);
func(button_x_2, button_y_2, label_x_2, label_y_2);
func(button_x_3, button_y_3, label_x_3, label_y_3);
//...
//==================================================
func( ID )
{
button_x_$ID$.Text = "some text 1";
button_y_$ID$.Text = "some text 1";
label_x_$ID$.Text = "some text 2";
label_y_$ID$.Text = "some text 2";
//...
}
func(1);
func(2);
func(3);
Everything is working fine, I just need to know is they any way around.
Because all I need is to send this simple integer (call it ID) that will then edit all those objects:
button_x_$ID$
button_y_$ID$
label_x_$ID$
label_y_$ID$
Only way I see here, as some sort of solution, is to make array:
B_X[1] = button_x_1;
B_X[2] = button_x_2;
B_X[3] = button_x_3;
B_Y[1] = button_y_1;
B_Y[2] = button_y_2;
B_Y[3] = button_y_3;
etc
But that create other problems like static and non static class members, I need to create huge lists of those array initialization and so on.
Last edited: