How to demonstrate Prefix Operator using C#?

CsharpProgrammingServer Side Programming

The increment operator is ++ operator. If used as prefix on a variable, the value of variable gets incremented by 1. After that the value is returned unlike Postfix operator. It is called Prefix increment operator. In the same way the decrement operator works but it decrements by 1.

For example,
++a;

The following is an example demonstrating Prefix increment operator −

Example

Live Demo

using System;

class Program {
static void Main() {
int a, b;

a = 10;
Console.WriteLine(++a);

b = a;
Console.WriteLine(a);
Console.WriteLine(b);
}
}

Output

11
11
11
Updated on 20-Jun-2020 15:16:55