I’ve seen them both being used in numerous pieces of C# code, and I’d like to know when to use i++ and when to use ++i?
(i being a number variable like int, float, double, etc).
I’ve seen them both being used in numerous pieces of C# code, and I’d
Share
Oddly it looks like the other two answers don’t spell it out, and it’s definitely worth saying:
i++means ‘tell me the value ofi, then increment’++imeans ‘incrementi, then tell me the value’They are Pre-increment, post-increment operators. In both cases the variable is incremented, but if you were to take the value of both expressions in exactly the same cases, the result will differ.