不能分配「AppendText」,因爲它是「方法組」。不能分配,因爲它在方法組C#中?
public partial class Form1 : Form
{
String text = "";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String inches = textBox1.Text;
text = ConvertToFeet(inches) + ConvertToYards(inches);
textBox2.AppendText = text;
}
private String ConvertToFeet(String inches)
{
int feet = Convert.ToInt32(inches)/12;
int leftoverInches = Convert.ToInt32(inches) % 12;
return (feet + " feet and " + leftoverInches + " inches." + " \n");
}
private String ConvertToYards(String inches)
{
int yards = Convert.ToInt32(inches)/36;
int feet = (Convert.ToInt32(inches) - yards * 36)/12;
int leftoverInches = Convert.ToInt32(inches) % 12;
return (yards + " yards and " + feet + " feet, and " + leftoverInches + " inches.");
}
}
錯誤發生在button1_Click方法內部的「textBox2.AppendText = text」行上。
謝謝你們。對不起,如果我是這樣一個白癡:( – puretppc
嗯我試過了,它的工作,但由於某種原因,它不會顯示在一個新的行 – puretppc
該文本框有'MultiLine = True'嗎?如果其中一個人下面回答你的問題,請點擊旁邊的勾號接受他們的回答 – Basic