January 18th, 2013, 04:33 PM
how to parse a text box to an integer - but....
If you have a form, with multiple text boxes. R1_fred, R2_fred, R3_fred -- and would like to parse what is in that text box into an integer, you could use:
risk = int.Parse(R1_fred.Text);
However, I'd like to replace "R1_" with "R2_" or "R3_". Unfortunately, I cannot do the following:
and expect it to work. What code could I use to effectively do the same thing?
string rowNumber = "R1_"
string temp1 = "fred.Text";
string temp2 = temp1.Insert (0, rowNumber);
risk = int.Parse(temp2);
Please be gentle, I am somewhat new to C#.
p.s. using .net 4.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!