日期:2014-05-17 浏览次数:20871 次
class Program
{
static void Increment(out int i,int inc=4)
{
i = 4;
}
static void Main(string[] args)
{
int i = 2;
Increment(out i);
}
}
static void Increment(out int i,int inc=4)
{
i += inc;
}
error CS0269: Use of unassigned out parameter 'i'
error CS0177: The out parameter 'i' must be assigned to before control leaves the current method
static void Increment(out int i,int inc=4)
{
i += inc; 等价于 i=i+inc; //i没赋值,所以出错了
}