C#: How to constuct a variable from another variables
Posted
by ozzwanted
on Stack Overflow
See other posts from Stack Overflow
or by ozzwanted
Published on 2010-04-22T17:18:36Z
Indexed on
2010/04/22
17:23 UTC
Read the original article
Hit count: 193
How to construct new variable in C#.
I mean, to have sth like this
public void updateXXX(string endingOfVariable, int newValue)
{
this.textBox_{endingOfVariable} = newValue;
}
This is implemented in Php:
$a = 'var'; $b = 'iable';
$variable = 'var';
echo ${$a.$b};
But maybe it is possible in C#.
The problem is that - I created ~500 textBoxes in C# Windows Form, and if I want to set a value, I need to build a switch() {case:; } statment with 500's cases.
© Stack Overflow or respective owner