如何返回值作为文本而不是void
?如何从方法返回字符串
实施例:
private void button1_Click(object sender, EventArgs e)
{
label1.Text = myvoid("foo", true);
//Error, Cannot imlicity convert type void to string
}
public void myvoid(string key , bool data)
{
if (data == true)
{
string a = key + " = true";
MessageBox.Show(a); //How to export this value to labe1.Text?
}
else
{
string a = key + " = false";
MessageBox.Show(a); //How to export this value to labe1.Text?
}
}
如何可以从返回而不是显示一个消息框空隙,一个方法分配值,并将其应用到label1.Text
?
'== == TRUE'坏 – Ryan 2012-07-19 16:52:34
我看到了'void' – 2012-07-19 16:55:24
好,不返回一个void,返回一个字符串..! – 2012-07-19 16:58:35