Home » ASP.NET Basics » 07 - Writing code and handling events
7

Increment and Decrement operators

Defining function and uses of operators and expressions

In C#, there are two operators used for increasing or decreasing the value of a variable by 1. The increment operator is denoted by ++ and the decrement operator is denoted by --.

For example, consider the following code:

 int num; num=10; num++;

After the last statement, the value of `num' becomes 11. Similarly,

 int num; num=10; num--;

The last statement will decrease the value of `num' by 1 and make it 9.