hello i having problem with this code
int i=10;
i=i++;
console.writeline(i);
//it is printing 10 at console why not 11 please tell me the details of compiler
hello i having problem with this code
int i=10;
i=i++;
console.writeline(i);
//it is printing 10 at console why not 11 please tell me the details of compiler
why i=i++ is undefined and have very strange behaviour
Geronimo
I believe the answer that you are getting is correct. You are assigning i to i then incrementing the original value of i by one. The value that is assigned is 10. if you were to change your code to read the following then you would get 11.
int i=10;
//actually all that you would have to do is ++i
// or you could change your code to read just i++, which would also give you 11
i=++i;
console.writeline(i);