Operators are symbols that perform specific operations on operands. They help us manipulate data and perform calculations. C# provides a rich set of operators to manipulate data.
๐๐ฟ๐ถ๐๐ต๐บ๐ฒ๐๐ถ๐ฐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐:
(Addition): Adds two operands.
(Subtraction): Subtracts the second operand from the first.
(Multiplication): Multiplies two operands. / (Division): Divides the first operand by the second. % (Modulo): Returns the remainder of the division operation.
๐๐ผ๐บ๐ฝ๐ฎ๐ฟ๐ถ๐๐ผ๐ป ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: == (Equal to) != (Not equal to)
(Greater than) < (Less than) = (Greater than or equal to) <= (Less than or equal to)
๐๐ผ๐ด๐ถ๐ฐ๐ฎ๐น ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐:
&& (Logical AND): Returns true if both operands are true. || (Logical OR): Returns true if at least one operand is true. ! (Logical NOT): Inverts the logical state of the operand.
๐๐๐๐ถ๐ด๐ป๐บ๐ฒ๐ป๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: = (Assignment) += (Add and assign) -= (Subtract and assign) *= (Multiply and assign) /= (Divide and assign) %= (Modulo and assign)
๐๐ถ๐๐๐ถ๐๐ฒ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: & (Bitwise AND) | (Bitwise OR) ^ (Bitwise XOR) ~ (Bitwise NOT) << (Left shift)
(Right shift)
๐๐ป๐ฐ๐ฟ๐ฒ๐บ๐ฒ๐ป๐ ๐ฎ๐ป๐ฑ ๐๐ฒ๐ฐ๐ฟ๐ฒ๐บ๐ฒ๐ป๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ๐: ++ (Increment) -- (Decrement)
๐๐ผ๐ป๐ฑ๐ถ๐๐ถ๐ผ๐ป๐ฎ๐น ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ (๐ง๐ฒ๐ฟ๐ป๐ฎ๐ฟ๐ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ผ๐ฟ): condition ? expression1 : expression2
๐๐ ๐ฎ๐บ๐ฝ๐น๐ฒ: int a = 10; int b = 5;
// Arithmetic Operations int sum = a + b; // 15 int difference = a - b; // 5 int product = a * b; // 50 int quotient = a / b; // 2 int remainder = a % b; // 0
// Comparison Operations bool isGreater = a > b; // true bool isEqual = a == b; // false
// Logical Operations bool isTrue = true && false; // false bool isFalse = !isTrue; // true
// Bitwise Operations int bitwiseAnd = a & b; // 0 int bitwiseOr = a | b; // 15 int bitwiseXor = a ^ b; // 15 int bitwiseNotA = ~a; // -11
// Shift Operations int leftShift = a << 1; // 20 int rightShift = a >> 1; // 5
// Increment and Decrement a++; // a becomes 11 b--; // b becomes 4
// Conditional Operator int maxValue = a > b ? a : b; // maxValue will be 11
// Assignment Operators a += 5; // a becomes 16 b -= 2; // b becomes 2
#csharp #dotnet #dotnetcore #programming #developer #softwaredevelopment #learnprogramming #operators #Arithmetic #Comparison #Logical #Bitwise #Shift #Increment #Decrement #Conditional #Assignment