0% found this document useful (0 votes)
0 views

5. Operators

The document provides an overview of operators in C#, including arithmetic, assignment, comparison, and logical operators. It explains the prefix and postfix methods for incrementing and decrementing values, as well as the use of assignment and comparison operators for variable manipulation and decision-making. The content is aimed at educating readers on the fundamental aspects of using operators in C# programming.

Uploaded by

sohanxt
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

5. Operators

The document provides an overview of operators in C#, including arithmetic, assignment, comparison, and logical operators. It explains the prefix and postfix methods for incrementing and decrementing values, as well as the use of assignment and comparison operators for variable manipulation and decision-making. The content is aimed at educating readers on the fundamental aspects of using operators in C# programming.

Uploaded by

sohanxt
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Operators

Sumaiya Tanjil Khan


Lecturer
Department of CSE
Uttara University
Operators in C#
• Arithmetic
• Assignment
• Comparison
• Logical
C# Arithmetic Operators
Increment

prefix increment
In this method, the operator precedes the operand (e.g., ++a). The
value of operand will be altered before it is used.
int a = 1;
int b = ++a; // b = 2
postfix increment
In this method, the operator follows the operand (e.g., a++). The value
operand will be altered after it is used.
int a = 1;
int b = a++; // b = 1
int c = a; // c = 2
Decrement

prefix decrement
In this method, the operator precedes the operand (e.g., – -a). The value of operand
will be altered before it is used.
int a = 1;
int b = --a; // b = 0
postfix decrement
In this method, the operator follows the operand (e.g., a- -). The value of operand will
be altered after it is used.
int a = 1;
int b = a--; // b = 1
int c = a; // c = 0
C# Assignment Operators

An assignment operator is used for assigning a value to a variable. The


most common assignment operator is =
C# Comparison Operators

Comparison operators are used to compare two values (or variables).


This is important in programming, because it helps us to find answers
and make decisions.
The return value of a comparison is either True or False.
Relational Operators
C# Logical Operators

As with comparison operators, you can also test for True or False values
with logical operators.
Logical operators are used to determine the logic between variables or
values:
Logical Operators
Thank You

You might also like