Operators in C#

anshikashrivastav 355 views 10 slides Jun 03, 2020
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

different operators in asp.net using C#


Slide Content

OperatorS IN C#

OPERATORS An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Operators can be categorized  based upon  their different  functionality  : Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators

Operators can also categorized  based upon Number of Operands : Unary Operator Binary Operator Ternary Operator

Arithmetic Operators Operator OPERATOR NAME + ADDITION OPERATOR - SUBTRATION OPERATOR * MULTIPLICATIONOPERATOR / DIVISION OPERATOR % MODULUS OPERATOR ++ INCREEMENT OPERATOR -- DECREEMENT OPERATOR These are used to perform arithmetic operations on operands.

Relational Operators Operator OPERATOR NAME == EQUAL TO != NOT EQUAL TO > GREATER THAN < LESS THAN >= GREATER THAN EQUAL TO <= LESS THAN EQUAL TO Relational operators are used for comparison of two values.

LOGICAL OPERATORS They are used to combine two or more conditions/constraints or to complement the evaluation of the original condition in consideration . Operator OPERATOR NAME Example Result && Logical And (5<2)&&(5>3) False || Logical Or (5<2)||(5>3) True ! Logical not !(5<2) True

BITWISE OPERATOR Bitwise and bit shift operators are used to perform bit level operations on integer ( int , long, etc ) and boolean data. Operator Operator Name Example ~ Bitwise Complement ( ~A) =-61 In 11000011 & Bitwise AND (A&B)=12, In 00001100 | Bitwise OR (A|B)=61, In 00111101 ^ Bitwise Exclusive OR(XOR) (A^B)=49, In 00110001 << Bitwise left Shift A<<2=240, In 11110000 >> Bitwise Right Shift A>>2=15, In 00001111

Assignment Operators Assignment operators are used to assigning a value to a variable. Ex: int a; a= 10; OPERATOR Operator Name Example = Value assign from right side to left operand C = A + B assigns value of A + B into C += Add and assign C += A is equivalent to C = C + A -= Subtract and assign C -= A is equivalent to C = C - A *= Multiply and assign C *= A is equivalent to C = C * A /= Devide and assign C /= A is equivalent to C = C / A %= Modulus and assign C %= A is equivalent to C = C % A

OPERATOR Operator Name Example <<= Left shift AND assignment operator C <<= 2 is same as C = C << 2 >>= Right shift AND assignment operator C >>= 2 is same as C = C >> 2 &= Bitwise AND assignment operator C &= 2 is same as C = C & 2 ^= bitwise exclusive OR and assignment operator C ^= 2 is same as C = C ^ 2 |= bitwise inclusive OR and assignment operator C |= 2 is same as C = C | 2

THANK YOU
Tags