【发布时间】:2013-11-15 08:30:55
【问题描述】:
无法分配“AppendText”,因为它是“方法组”。
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”行。
【问题讨论】:
-
谢谢大家。对不起,如果我是个白痴:(
-
嗯,我试过了,它工作,但由于某种原因,它不会在新行中显示它。
-
文本框有
MultiLine = True吗?此外,如果以下人员之一确实回答了您的问题,请点击旁边的勾号接受他们的回答 -
是的,我将属性设置为 true,但它仍然不起作用。 :(
-
在要附加的文本后添加一个新行:
textBox2.AppendText(text + Environment.NewLine);
标签: c# .net methods assign method-group