I++ Vs ++i ( C# Interview Questions On Postfix And Prefix)

In this video, we will try to understand what is the difference between I + + + + + I. Now, this looks to be a very silly question, and it is a silly question, actually, but the amount of confusion I see around, you know, has provoked me to create this video. So in order to understand the concept now, let me go and write a very simple code here. So you can see that I have defined a very simple variable here called as I and I have assigned the value of is 1. And there is a second variable. I. Am I defining.

Called a J and let's say, I am saying first here, I, plus. So let me go and put a debug point here. And let me go and run this application. And what I will do is I go and pin the variable J. And let me also go and pin the variable I, ok. So pin pen. Ok, right?

So you can see here is the J value. And here is the value. Right now you can see here, the value of j is 1.

And the value of I is 2. In other words, what has happened here is first the value of I have been assigned to j. And then the value of I have. Been incremented so when you do, I plus first, the value is assigned, or it is returned. And then the increment happens.

Now let me go and make it plus I. So let me now change this to plus I. And let me again, run this application in a debug mode. Now, look at the values of j.

And I the value of j is 2. And the value of I is 1 Y is 2. In other words, what happened here is first the increment happens and then the values assigned.

So when you do a plus I, first, the increment is done and. Then the value is returned to the other variable. So if you visualize in a pictorial form at I, plus is a postfix, in other words, it first assigns and then increments while plus I is a prefix it first increments and then assigns, so I hope that you enjoyed this video in this video, we were trying to understand what is the difference between AI + + + + + I.