Skip to content

JA CSharp Operators

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

演算子と評価順序

マニュアルC# · 例題UO

グループ オペレーター
算術 + - * / % ++ --
比較 == != < > <= >=
ロジック `! &&
ビット `~ &
プリズバイバニー `= += -= *= /= %= &=
条件と null ?: ?? ?. ?[]
型とオブジェクト is as typeof sizeof new default
アクセスと範囲 . [] ^ ..

整数の除算では小数部分が切り捨てられます。 && および || は、必要な場合にのみ 2 番目のオペランドを評価します。括弧は表現の順序を明示します。 & と | は、両方のオペランドを評価して bool に適用することもできます。

簡単な例 (Example.cs)

この例を Example.cs として別に保存し、このページの他の例とは独立して実行してください。

Example.cs:

// PROJECT-EXAMPLE
System.Console.WriteLine(2 + 3 * 4);
System.Console.WriteLine((2 + 3) * 4);

結果:

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}");

公式ドキュメント: オペレーターと評価 - Microsoft Learn。

Clone this wiki locally