public class COne
{
public COne()
{
//
// TODO: Add constructor logic here
//
}
public string testOut(out int i)
{
try
{
i=5;
// Other statements use i here...
}
catch(Exception ee)
{
return ee.Message;
}
return "";
}
}
我现在testOne
COne one=new COne();
int i=0;
// Statements use i here...
if(one.testOut(out i)=="")
MessageBox.Show(i.ToString());
报错:
The out parameter 'i' must be assigned to before control leaves the current method
再加一个问题
看下面的例程
public class COne
{
public COne()
{
//
// TODO: Add constructor logic here
//
}
public string testOut(out int i)
{
try
{
i=5;
}
catch(Exception ee)
{
return ee.Message;
}
return "";
}
}
我现在testOne
COne one=new COne();
int i=0;
if(one.testOut(out i)=="")
MessageBox.Show(i.ToString());
报错:
The out parameter 'i' must be assigned to before control leaves the current method