codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🔷

C# Programming

5 / 60 topics
1Getting Started with C#2C# Syntax3Variables in C#4Data Types in C#5Operators in C#
Tutorials/C# Programming/Operators in C#
🔷C# Programming

Operators in C#

Updated 2026-05-15
10 min read

Operators in C#

Introduction

In programming, operators are symbols that perform operations on variables and values. C# provides a wide range of operators to handle various tasks such as arithmetic calculations, comparisons, and logical operations. Understanding these operators is fundamental for writing effective and efficient C# code.

Concept

Arithmetic Operators

Arithmetic operators are used to perform basic mathematical operations like addition, subtraction, multiplication, division, and modulus (remainder).

  • Addition (+): Adds two numbers.
  • Subtraction (-): Subtracts the second number from the first.
  • Multiplication (*): Multiplies two numbers.
  • Division (/): Divides the first number by the second. If both operands are integers, the result is an integer (integer division). If at least one operand is a floating-point number, the result is a floating-point number (floating-point division).
  • Modulus (%): Returns the remainder of the division of two numbers.

Comparison Operators

Comparison operators are used to compare two values and return a Boolean result (true or false). These operators are essential for decision-making in your programs.

  • Equal to (==): Checks if two values are equal.
  • Not equal to (!=): Checks if two values are not equal.
  • Greater than (>): Checks if the first value is greater than the second.
  • Less than (<): Checks if the first value is less than the second.
  • Greater than or equal to (>=): Checks if the first value is greater than or equal to the second.
  • Less than or equal to (<=): Checks if the first value is less than or equal to the second.

Logical Operators

Logical operators are used to combine multiple conditions and return a Boolean result. They are commonly used in control structures like if statements.

  • Logical AND (&&): Returns true if both conditions are true.
  • Logical OR (||): Returns true if at least one condition is true.
  • Logical NOT (!): Inverts the Boolean value of a condition. If the condition is true, it becomes false, and vice versa.

Examples

Let's explore each type of operator with practical examples.

Arithmetic Operators

int a = 10;
int b = 5;

// Addition
int sum = a + b; // sum = 15

// Subtraction
int difference = a - b; // difference = 5

// Multiplication
int product = a * b; // product = 50

// Division
double quotient = (double)a / b; // quotient = 2.0

// Modulus
int remainder = a % b; // remainder = 0

Comparison Operators

int x = 10;
int y = 5;

bool isEqual = x == y; // isEqual = false
bool isNotEqual = x != y; // isNotEqual = true
bool isGreater = x > y; // isGreater = true
bool isLess = x < y; // isLess = false
bool isGreaterOrEqual = x >= y; // isGreaterOrEqual = true
bool isLessOrEqual = x <= y; // isLessOrEqual = false

Logical Operators

bool condition1 = true;
bool condition2 = false;

// Logical AND
bool andResult = condition1 && condition2; // andResult = false

// Logical OR
bool orResult = condition1 || condition2; // orResult = true

// Logical NOT
bool notResult = !condition1; // notResult = false

What's Next?

Now that you have a solid understanding of operators in C#, the next step is to learn about control structures such as if, else, switch, and loops. These structures allow your programs to make decisions and repeat actions based on certain conditions, making them more dynamic and interactive.

Stay tuned for our next tutorial on "Control Structures in C#"!


PreviousData Types in C#Next Control Structures in C#

Recommended Gear

Data Types in C#Control Structures in C#