Increment and decrement operators in C#

In C# Programming language we use increment and decrements operators for increase or Decrease value of variables.these variables are used as prefix and post-fix expression .in this C# code we will see how to use them in program.

Increment and decrement operator in C#

In C Sharp increment and decrement operator are use for increase and decrease value of operands by 1. in C# we have unary operators ++ and --. ++ is use for increase value and -- use for decrease value. unary operator give diffrent result as their position ,postfix or prefix.When ++ operator is prefixed with operands it first adds1 to the operand and then the result is assigned to variable on the left hand side.Whereas,when you postfix ++ operator in operand,it first assigns the value to variable on the left hand side and then increment the operand.
Lets see example of using increment operator and assignment for you is make same program with -- operator that Decrease value.

using System;
class InCrement

public static void Main()
int x=20,y=15;

System.Console.WriteLine(" x= "+x);
System.Console.WriteLine(" y= "+y);

System.Console.WriteLine(" ++x= " + ++x);

System.Console.WriteLine(" y++= "y++);
System.Console.WriteLine(" x= "+x);


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: