.

# Operators in C# Assignment Help

OPERATORS

Operators are used to perform some operations with values using symbols.

The list of operators supported in c#

• Arithmetic Operators
• Relational Operators
• Bitwise Operators
• Logical Operators
• Assignment Operators
• Misc Operators

Arithmetic Operators

It is used to perform basic mathematical operations. It is considered x=4, y=2

## Operators in C# Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com

 Operator Name Description Example + Addition Adds two value x+y=6 - Subtraction Subtracts the values x-y=2 * Multiplication Multiplies two values x*y=8 / Division Divides value x/y=2 % Modulas Returns the reminder x%y==0 ++ Increment Increases the value by 1 ++x=5 -- Decrement Decreases value by 1 --x=3

Relational Operators

It is used to relate various kind of relation between two operands. It is considered x=4, y=2

 Operator Name Description Example == Equal to Check if two values are equal x==y is False !=Not equal to Check if two values are not equal x!=y is True >Greater than Check left side value is larger than right side value x>y is True = Greater than equal to Check left side value is larger or equal to right side value x>=y is True <= Less than equal to Check left side value is less than or equal to right side value x<=y is False

Bitwise Operators

It works on bits level and performs bit by bit movement. It is considered x=11, y=22

 Operator Name Description Example Answer & Bitwise and copies a bit to the result if both operands are exist. x&y 200000010 | Bitwise or copies a bit to the result if any one operands are exist. x|y 31 00011111 ^ Bitwise XOR copies a bit to the result if not both operands but set in one. x^y 29 00011101 ~Bitwise Compliment effect of 'flipping' bits ~x -12 11110100 << Left shift The left side value is moved left by the number of bits specified by the right side value x<<2 44 00101100 >> Right shift The right side value is moved right by the number of bits specified by the right side value x>>2 2 00000010

Logical Operators

Two or more than two relations can be logically coupled together using logical operators.

It is considered x holds true and y holds false

 Operator Name Description Example && Logical and If both the operands are non-zero, then it is true. x&&y is False || Logical or If any one of the operands are non-zero, then it is true. x||y is True ! Logical not If both conditions makes true logical not make it false !(x&&y) is True

Assignment Operators

An assignment operator assigns a value to its left hand operand based on the value of its right hand operand.

 Operator Name Description Example = Simple assignment Assign values right side to left side x=y += Add AND assignment Add right to left and assign to left operand x+=y -= subract AND assignment subtract right to left and assign to left operand x-=y *= Multiply AND assignment multiply right with left and assign to left operand x*=y /= Divide AND assignment divide right with left and assign to left operand x/=y %= Modulus AND assignment Modulus of two operand and assign to left operand x%=y <<= Left shift AND assignment Left shift AND assign value x<<=3 >>= Right shift AND assignment Right shift AND assign value x>>=3 &= Bitwise AND assignment Bitwise AND assign value x&=3 |= Bitwise inclusive or assignment Bitwise inclusive or assign value x|=3 ^= Bitwise exclusive or assignment Bitwise exclusive or assign value x^=3

Miscellaneous Operators

Other missing important operators are included here

 Operator Description Example sizeof() Returns the data type size. sizeof(int), is 4. typeof() Returns the classNametype typeof(StreamReader); & Returns the variable address. &a; returns actual address of the variable. ? : Conditional operator if Condition is true? Then value X : Otherwise value Y * Pointer to a variable. *a; creates pointer with the name 'a' to a variable. as Cast without raising an exception if the cast fails. Object obj = new StringReader("Well"); StringReader r = obj as StringReader; is Identifies whether an object is of a definite type. if( BMW is Car) // checks if BMW is an object of the Car className.
.