val++ 与++val 输出结果一样吗? 为什么?
class Program
{
static void Main(string[] args)
{
int sum=0,val=0;
while(val<=10)
{
sum += val;
++val;
}
Console.WriteLine(sum.ToString());
}
}
class Program
{
static void Main(string[] args)
{
int sum=0,val=0;
while(val<=10)
{
sum += val;
val++;
}
Console.WriteLine(sum.ToString());
}
}
val=0 与val=1输出结果一样吗?为什么?
class Program
{
static void Main(string[] args)
{
int sum=0,val=0;
while(val<=10)
{
sum += val;
++val;
}
Console.WriteLine(sum.ToString());
}
}
class Program { static void Main(string[] args) { int sum=0,val=1; while(val<=10) { sum += val; ++val; } Console.WriteLine(sum.ToString()); } }