Skip to content

Commit

Permalink
doc: update docs/cs.md (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Feb 28, 2023
1 parent c39abea commit 2c858eb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/cs.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ foreach(int num in numbers) {
}
```


C# 数据类型
---------------------

Expand All @@ -140,7 +139,7 @@ C# 数据类型
| float | 单精度浮点型 | Single | 4 | ±1.5x10^45 ~ ±3.4x10^38 |
| double | 双精度浮点型 | Double | 8 | ±5.0x10^-324 ~ ±1.7x10^308 |
| N/A | 指针型 | IntPtr | 与指针相同 | 与指针相同(受操作系统和处理器位宽影响) |
| N/A | 无符号指针型 | UIntPtr | 与指针相同 | 与指针相同(受操作系统和处理器位宽影响) |
| N/A | 无符号指针型 | UIntPtr | 与指针相同 | 与指针相同(受操作系统和处理器位宽影响) |
<!--rehype:className=show-header-->

### 基本数据类型
Expand All @@ -149,7 +148,7 @@ C# 数据类型
| -------------------------------- | ------------ | ----------- | ------------------------------------------------------------------ |
| (除指针型外的全部原始数据类型) | | | 原始数据类型都是值类型,基本数据类型包含部分本质上是引用的数据类型 |
| string | 字符串 | String | 可变长度 |
| decimal | 十进制浮点数 | Decimal | 适合处理货币等计算,16字节长,不遵循 IEEE 754 关于浮点数的规则 |
| decimal | 十进制浮点数 | Decimal | 适合处理货币等计算,16字节长,不遵循 IEEE 754 关于浮点数的规则 |
<!--rehype:className=show-header-->

C# 字符串
Expand Down Expand Up @@ -259,14 +258,17 @@ Console.WriteLine(Rep);
```

### 逻辑运算
<!--rehype:wrap-class=col-span-2-->

```cs
//或运算, 与运算, 非运算
bool A = true;
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() {
Expand All @@ -279,8 +281,10 @@ bool F = C & CalcD(); // C:false, D: true, F: false
//异或运算
bool Xor = A ^ B;
```
C#中的逻辑运算支持可空布尔类型运算. 注意条件逻辑运算不支持可空布尔类型.
x | y | x&y | x\|y | x^y | !x

C# 中的逻辑运算支持可空布尔类型运算. 注意条件逻辑运算不支持可空布尔类型.

x | y | x&y | x\|y | x^y | !x
:- | - | --- | --- | --- | --
true | true | true | true | false | false
true | false | false | true | true | false
Expand Down

0 comments on commit 2c858eb

Please sign in to comment.