C# Unary Operators

The C# unary operator is wide used for increment or decrement value by one. This operator wide used with loop constructs to increment loop by one. it’s terribly straightforward to use and understand C# unary operators. a complete detail about this operator is given below with complete example.

This operator is pronounced as increment operator. it’s used for incrementing price by one. it’s used in C# programming by 2 types: Pre-increment (++i) and Post-increment (i++). In pre-increment, first it increments by one then loop executes whereas in Post-increment, the loop executes then it increments by one.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UnaryOperatorExample
 class Program
 static void Main(string[] args)
 int i = 0; // initialization
 i++; // i incremented by one. It is post increment
 Console.WriteLine("The value of i is {0}", i);

Leave a Reply

Your email address will not be published. Required fields are marked *