+ 2
Really struggling with prefix and postfix operators
Can anybody help with some well explained examples, more the better.
3 Answers
+ 5
for example:
int x = 1;
Console.WriteLine(x++);
//It will print 1 then after printing, the x will be incremented by one.
--
int x = 1;
Console.WriteLine(++x);
//the x will be incremented by one, then it will print 2.
Hope that helps! :))
+ 3
prefix- first operate on the variable and then use the value
postfix- first use the value and then operate on the variable
+ 2
thanks for an example @erwin