Repository navigation
EN CSharp Operators
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
| Group | Operators |
|---|---|
| Arithmetic | + - * / % ++ -- |
| Comparison | == != < > <= >= |
| Logic | `! && |
| Bits | `~ & |
| Assignment | `= += -= *= /= %= &= |
| Conditions and null | ?: ?? ?. ?[] |
| Types and objects | is as typeof sizeof new default |
| Access and ranges | . [] ^ .. |
Integer division discards the fractional part. && and || evaluate the second operand only when necessary. Parentheses make the order of expression explicit. & and | can also be applied to bool, evaluating both operands.
Save this example separately as Example.cs. Run it independently of the other examples on this page.
Example.cs:
// PROJECT-EXAMPLE
System.Console.WriteLine(2 + 3 * 4);
System.Console.WriteLine((2 + 3) * 4);Result:
14
20
int hp = 50;
int maximum = 100;
bool shouldWait = maximum > 0 && hp * 100 / maximum < 60;
string state = shouldWait ? "low" : "ready";
UO.Print(state);int flags = 0b0010;
flags |= 0b0100;
bool hasFlag = (flags & 0b0100) != 0;
UO.Print($"Mask={flags}, enabled={hasFlag}");Official documentation: Operators and Evaluation - Microsoft Learn.
ClassicUO — Bad Newbie & C# Scripts IDE