0
I have doubt on increment and decrement operators in c# can anyone help me
2 ответов
0
Increment/decrement operators increase/decrease value of operand by 1
They are represented as. ++/--
but there is difference between placing them. e.g ++a and a++ are different.
1.Let,(pre-increment)
int a=3;
Console.Writeline(++a);
//here output is 4
//after the above statement value of a becomes 4
2.Let,(post-increment)
int a=8;
Console.Writeline(a++);
//here output is still 8
//after the above statement value of a becomes 9
Inshort, if the increment operator is before the operand then value increases by 1 on the same statement and when increment operator is after the operand increment take place but after that statement(in which it is incremented)
Same is with decrement operator
0
Thank you