(using WPF)
Is it possible to use the number of a TextBox to select the parameter name?
For example, the user can put 0,1,2 or 3 as text in the TextBox:
private void button1_Click(object sender, RoutedEventArgs e)
{
int test = int.Parse(textBox1.Text);
string nr1 = "this string is 1";
string nr2 = "this string is 2";
string nr3 = "this string is 3";
MessageBox.Show();
}
Now for MessageBox.Show(); in want to put something as nr(test)
Would something like this be possible?
Why not use a Dictionary ?
var dict = new Dictionary<int,string>();
dict.Add(1,"String Number 1");
dict.Add(2,"String Number 2");
dict.Add(3,"String Number 3");
int test = int.Parse(textBox1.Text);
MessageBox.Show(dict[test]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With