Operators in C#

Operators are symbols that are used to perform operations on operands. Operands may be variables and/or constants.

Let's Take an Example: + Operator
int a = 5 + 5;
int b = 10 + a;
int c = a + b;

In the above taken example, + operator adds two number literals and assign the result to a variable. It also adds the values of two int variables and assigns the result to a variable.

C# supports a number of operators that are classified based on the type of operations they perform.

1. Basic Assignment Operator

Basic assignment operator (=) is used to assign values to variables.

Let's Take an Example: Basic Assignment Operator
using System;
namespace Operator
	class BasicAssignmentOperator
		public static void Main(string[] args)
			int iFirstNumber, iSecondNumber;
			// Assigning a constant value to variable
            iFirstNumber = 10;
			Console.WriteLine("i) Number = {0}", iFirstNumber);
			// Assigning a variable to another variable
            iSecondNumber = iFirstNumber;
			Console.WriteLine("ii) Number = {0}", iSecondNumber);

When we execute the program, the output will be:

First Number = 10
Second Number = 10