如何返回值作爲文本而不是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