Operator एक Symbol है जो Compiler को Specific Mathematical या Logical Manipulations Perform करने के लिए कहता है।
| Operator | Description | Example |
|---|---|---|
| + | दो Operands को Add करता है | A + B = 30 |
| - | Second Operand को First से Subtract करता है | A - B = -10 |
| * | दोनों Operands को Multiply करता है | A * B = 200 |
| / | Numerator को De-numerator से Divide करता है | B / A = 2 |
| % | Modulus Operator और Integer Division के बाद Remainder | B % A = 0 |
| ++ | Increment Operator Integer Value को One से Increase करता है | A++ = 11 |
| -- | Decrement Operator Integer Value को One से Decrease करता है | A-- = 9 |
आइए C# में Arithmetic Operators का उपयोग करने का एक Example देखते हैं।
Example
using System; namespace Demo { class Program { static void Main(string[] args) { int a = 99; int b = 33; int c; c = a + b; Console.WriteLine("Value of c is {0}", c); c = a - b; Console.WriteLine("Value of c is {0}", c); c = a * b; Console.WriteLine("Value of c is {0}", c); c = a / b; Console.WriteLine("Value of c is {0}", c); c = a % b; Console.WriteLine("Value of c is {0}", c); c = a++; Console.WriteLine("Value of c is {0}", c); c = a--; Console.WriteLine("Value of c is {0}", c); Console.ReadLine(); } } }Output
Value of c is 132 Value of c is 66 Value of c is 3267 Value of c is 3 Value of c is 0 Value of c is 99 Value of c is 100