I am using a StringReader
to read input from a multi-line textbox. However, I am experiencing strange behaviour.
My Code:
string x = reader.ReadLine();
int y = int.Parse(x);
x
is always an int.
My problem is that since x
is the first line of the multiline textbox, it doesn't contain just the int, but System.Windows.Forms.Textbox, Text:10
Any help here?
I create the StringReader
as following:
using (StringReader reader = new StringReader(Convert.ToString(multilinetbox)))
{
}
Change your reader to read the Text
property of the multiline textbox, instead of the entire control:
using (StringReader reader = new StringReader(multilinetbox.Text))