๐—–# ๐—ข๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ผ๐—ฟ๐˜€:

๐—–# ๐—ข๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ผ๐—ฟ๐˜€:

ยท

2 min read

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

ย