C#Windows窗体 - 奇怪的多行文本框行为

Сте*_*чев 1 c# textbox multiline winforms stringreader

我使用a StringReader来读取多行文本框中的输入.但是,我遇到了奇怪的行为.
我的代码:

string x = reader.ReadLine();
int y = int.Parse(x);
Run Code Online (Sandbox Code Playgroud)

x总是一个int.
我的问题是,因为x是多行文本框的第一行,它不仅包含int,但是System.Windows.Forms.Textbox, Text:10
这里有任何帮助吗?

我创建StringReader如下:

using (StringReader reader = new StringReader(Convert.ToString(multilinetbox)))
{

}
Run Code Online (Sandbox Code Playgroud)

Bla*_*hma 5

更改您的阅读器以阅读Text多行文本框的属性,而不是整个控件:

using (StringReader reader = new StringReader(multilinetbox.Text))
Run Code Online (Sandbox Code Playgroud)