Subscribe - It's FREE!!

Stay Connected Here

Stay Updated With Us Here


What is the difference between i++ and ++i in C#

Share with WhatsApp

In this post I will share some information about incremental operator ++ of C#. In many interviews this question has been already asked and still it is one of the favorite question for some of the interviewers i.e. What is the difference between i++ and ++I in C#?

So let’s check what the difference is.

In both the cases value of “i” gets incremented but the difference is i++ - It’s a type of post increment. When you write i++ it means “give me the value of i and then increment its value”, on the other hand ++i means “increment the value of i and then give me the updated value”.

Let’s understand using some example.

If you write a code like below.

int i = 2;

int j= 2;

int k = i++;

int l = ++j;

In above case, at the end, values of i,j,k and l will be like following

i = 3

j = 3

k =2

l = 3

So by above example you can easily understand how pre increment and post increment works.

If not and having some queries do share in comment section below. If you have something positive to add this short but useful post then do share that too. Thanks.

If you enjoyed this post take 5 seconds to share it! Be Socialable. :-)

Share with WhatsApp

Posts To Read Next

Typewriter - Automatic TypeScript Template generation from C# classes in Visual Studio

Typewriter, an extension for visual studio that generates TypeScript files from C# code files using TypeScript templates. Convert your C# model classes to TypeScript automatically.

Swagger - Powerful Opensource Framework for RESTful API

With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. Swagger Editor allows you to generate code, documentation with ease.

Assembla - Free and private repository to manage your source code online with SVN subversion hosting

With Assembla you can share source code with others online. Free & Private source code repository with SVN Subversion, Git & Perforce Hosting.

Top 10 Visual Studio things which can boost developers coding speed

Visual Studio 2012 provides some coding features by which you can code faster if use them properly. This post will cover top 10 things among them to boost your development speed.

Visual Studio Code - Lighweight but powerful source code editor available for Windows, OS X and Linux

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, OS X and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (C++, C#, Python, PHP) and runtimes.

Your opinion is valuable for us! Comments, suggetions are welcome.

Submit your Email Id to stay updated with us and get notified with our new posts. It's FREE!
Vu 32'' TV Vu 24'' TV
We know this popup is disturbing you!
But We would greatly appreciate if you share us with your friends below!

It will not take more than 2 seconds but will motivate us greatly to write more,share more!