I found a problem with C# and post increments. I was going
through some source code in c++ and found someone did a
post increment:
int x=0;
for(int i=0; i<10; i++)
{
x = x++;
}
In c++, you'd get 0,1,...,9 (as expected). This doesn't
work in C#. In C#, you get 0,...,0. It seems the post
increment is ignored in this case. However, the lines:
x=4;
y=x++;
produces y=4, x=5 (as expected)
Should c# be behaving this way or is there a compiler
error? After looking at the assembly code in c++ and c#, it
looks like a bug in c#.
through some source code in c++ and found someone did a
post increment:
int x=0;
for(int i=0; i<10; i++)
{
x = x++;
}
In c++, you'd get 0,1,...,9 (as expected). This doesn't
work in C#. In C#, you get 0,...,0. It seems the post
increment is ignored in this case. However, the lines:
x=4;
y=x++;
produces y=4, x=5 (as expected)
Should c# be behaving this way or is there a compiler
error? After looking at the assembly code in c++ and c#, it
looks like a bug in c#.
Comment