doc: update docs/cs.md (#316)

This commit is contained in:
jaywcjlove 2023-02-28 23:18:56 +08:00
parent c39abea00a
commit 2c858eb744

View File

@ -118,7 +118,6 @@ foreach(int num in numbers) {
}
```
C# 数据类型
---------------------
@ -259,6 +258,8 @@ Console.WriteLine(Rep);
```
### 逻辑运算
<!--rehype:wrap-class=col-span-2-->
```cs
//或运算, 与运算, 非运算
bool A = true;
@ -266,7 +267,8 @@ bool B = false;
bool Or = A || B; // = A | B
bool And = A && B; // = A & B
bool Not = !A;
// ||,&& 与 |,& 分别为逻辑运算和条件逻辑运算, 两者的区别在于, 前者仅在必要时才会计算右侧的值, 后者始终计算右侧的值. 例如:
// ||,&& 与 |,& 分别为逻辑运算和条件逻辑运算, 两者的区别在于,
// 前者仅在必要时才会计算右侧的值, 后者始终计算右侧的值. 例如:
bool C = false;
bool D = true;
bool CalcD() {
@ -279,7 +281,9 @@ bool F = C & CalcD(); // C:false, D: true, F: false
//异或运算
bool Xor = A ^ B;
```
C#中的逻辑运算支持可空布尔类型运算. 注意条件逻辑运算不支持可空布尔类型.
C# 中的逻辑运算支持可空布尔类型运算. 注意条件逻辑运算不支持可空布尔类型.
x | y | x&y | x\|y | x^y | !x
:- | - | --- | --- | --- | --
true | true | true | true | false | false