+ 2

Really struggling with prefix and postfix operators

Can anybody help with some well explained examples, more the better.

26th Jun 2016, 1:04 PM
Jordan Herrera
Jordan Herrera - avatar
3 Antworten
+ 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! :))
26th Jun 2016, 4:13 PM
Erwin Mesias
Erwin Mesias - avatar
+ 3
prefix- first operate on the variable and then use the value postfix- first use the value and then operate on the variable
26th Jun 2016, 2:05 PM
Mukul Kumar
Mukul Kumar - avatar
+ 2
thanks for an example @erwin
26th Jun 2016, 4:50 PM
Mukul Kumar
Mukul Kumar - avatar