0

I have doubt on increment and decrement operators in c# can anyone help me

20th Mar 2020, 12:30 PM
Rajani Upadhyay
Rajani Upadhyay - avatar
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
20th Mar 2020, 4:42 PM
Muhammad Bilal
Muhammad Bilal - avatar
0
Thank you
21st Mar 2020, 4:13 AM
Rajani Upadhyay
Rajani Upadhyay - avatar