你以前试过这个吗?
static void Main(string[] args)
{
int x = 10;
x = x++;
Console.WriteLine(x);
}
Run Code Online (Sandbox Code Playgroud)
产量:10.
但对于
static void Main(string[] args)
{
int x = 10;
x++;
Console.WriteLine(x);
}
Run Code Online (Sandbox Code Playgroud)
产量:11.
谁能解释为什么这个?
我很难理解用C#递增变量之间的区别是什么:
myInt++;
Run Code Online (Sandbox Code Playgroud)
和
++myInt;
Run Code Online (Sandbox Code Playgroud)
什么时候你会使用哪一个?
我会给voteCount ++以获得最佳答案.或者我应该给它++ voteCount ...