如何从文本框的值中设置字符串值

问题描述:

我试图从TextBox值中设置一个字符串:如何从文本框的值中设置字符串值

E.g.

private void testing_Click(object sender, EventArgs e) 
     { 

      Set <string> = TextBox.Text 

     } 

这怎么办?

+0

你是不是想给TextBox.Text值赋给一个字符串变量或创建一个集包含TextBox.Text? – FishBasketGordo

您不需要单词集,如果已经声明了字符串,则可以删除该单词。

string yourString = TextBox.Text; 
+0

你甚至不需要说你可以使用的字符串var yourstring = TextBox.Text – boca

private void testing_Click(object sender, EventArgs e) 
{ 
    string textOfTextBox = ((TextBox) sender).Text; 
    MessageBox.Show (textOfTextBox); 
}