💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[C# 运算符和表达式 - C# 参考 | Microsoft Learn](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/) | 运算符 | 类别或名称 | | --- | --- | | [x.y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#member-access-expression-)、[f(x)](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#invocation-expression-)、[a\[i\]](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#indexer-operator-)、[`x?.y`](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-)、[`x?[y]`](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-)、[x++](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#increment-operator-)、[x--](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#decrement-operator---)、[x!](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/null-forgiving)、[new](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/new-operator)、[typeof](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/type-testing-and-cast#typeof-operator)、[checked](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/keywords/checked)、[unchecked](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/keywords/unchecked)、[default](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/default)、[nameof](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/nameof)、[delegate](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/delegate-operator)、[sizeof](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/sizeof)、[stackalloc](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/stackalloc)、[x->y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/pointer-related-operators#pointer-member-access-operator--) | 主要 | | [+x](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#unary-plus-and-minus-operators)、[\-x](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#unary-plus-and-minus-operators)、[](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#logical-negation-operator-)x[、](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#bitwise-complement-operator-)~x[、](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#increment-operator-)++x[、](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#decrement-operator---)\--x[、](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#index-from-end-operator-)^x[、](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/type-testing-and-cast#cast-expression)(T)x[、](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/await)await[、&&x](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/pointer-related-operators#address-of-operator-)、[\*x](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/pointer-related-operators#pointer-indirection-operator-)、[true 和 false](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/true-false-operators) | 一元 | | [x..y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/member-access-operators#range-operator-) | 范围 | | [switch](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/switch-expression)、[with](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/with-expression) | `switch`和`with`表达式 | | [x \* y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#multiplication-operator-)、[x / y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#division-operator-)、[x % y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#remainder-operator-) | 乘法 | | [x + y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#addition-operator-)、[x – y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#subtraction-operator--) | 加法 | | [x > y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#right-shift-operator-) | Shift | | [x y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/comparison-operators#greater-than-operator-)、[x = y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/comparison-operators#greater-than-or-equal-operator-)、[is](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/type-testing-and-cast#is-operator)、[as](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/type-testing-and-cast#as-operator) | 关系和类型测试 | | [x == y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/equality-operators#equality-operator-)、[x != y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/equality-operators#inequality-operator-) | 相等 | | `x & y` | [布尔逻辑 AND](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#logical-and-operator-)或[按位逻辑 AND](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#logical-and-operator-) | | `x ^ y` | [布尔逻辑 XOR](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#logical-exclusive-or-operator-)或[按位逻辑 XOR](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#logical-exclusive-or-operator-) | | `x | y` | [布尔逻辑 OR](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#logical-or-operator-)或[按位逻辑 OR](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#logical-or-operator-) | | [x && y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#conditional-logical-and-operator-) | 条件“与” | | [x || y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#conditional-logical-or-operator-) | 条件“或” | | [x ?? y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/null-coalescing-operator) | Null 合并运算符 | | [c ? t : f](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/conditional-operator) | 条件运算符 | | [x = y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/assignment-operator)、[x += y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#compound-assignment)、[x -= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#compound-assignment)、[x \*= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#compound-assignment)、[x /= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#compound-assignment)、[x %= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/arithmetic-operators#compound-assignment)、[x &= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#compound-assignment)、[x |= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#compound-assignment)、[x ^= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/boolean-logical-operators#compound-assignment)、[x >= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators#compound-assignment)、[x ??= y](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/null-coalescing-operator)、[\=>](https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/lambda-operator) | 赋值和 lambda 声明 |