doc: update docs/cs.md #584
This commit is contained in:
parent
21dc25c2a4
commit
2dd3fd1e84
81
docs/cs.md
81
docs/cs.md
@ -67,7 +67,23 @@ Console.WriteLine(name); // => John Doe
|
|||||||
|
|
||||||
查看: [C#字符串](#c-字符串)
|
查看: [C#字符串](#c-字符串)
|
||||||
|
|
||||||
|
### 注释
|
||||||
|
|
||||||
|
```cs
|
||||||
|
// 单行注释
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 多行
|
||||||
|
* 注释 - 用于文档
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// 向IDE中的任务列表添加注释(VS、Rider都支持)
|
||||||
|
/// XML 单行注释,用于文档
|
||||||
|
```
|
||||||
|
|
||||||
### 用户输入
|
### 用户输入
|
||||||
|
<!--rehype:wrap-class=col-span-2-->
|
||||||
|
|
||||||
```cs showLineNumbers
|
```cs showLineNumbers
|
||||||
Console.WriteLine("Enter number:");
|
Console.WriteLine("Enter number:");
|
||||||
@ -78,6 +94,19 @@ if(int.TryParse(Console.ReadLine(),out int input))
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 条件判断
|
||||||
|
|
||||||
|
```cs
|
||||||
|
int j = 10;
|
||||||
|
if (j == 10) {
|
||||||
|
Console.WriteLine("I get printed");
|
||||||
|
} else if (j > 10) {
|
||||||
|
Console.WriteLine("I don't");
|
||||||
|
} else {
|
||||||
|
Console.WriteLine("I also don't");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### 变量
|
### 变量
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
@ -94,47 +123,8 @@ var str = "999";
|
|||||||
var bo = false;
|
var bo = false;
|
||||||
```
|
```
|
||||||
|
|
||||||
### 注释
|
|
||||||
|
|
||||||
```cs
|
|
||||||
// 单行注释
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 多行
|
|
||||||
* 注释 - 用于文档
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// 向IDE中的任务列表添加注释(VS、Rider都支持)
|
|
||||||
/// XML 单行注释,用于文档
|
|
||||||
```
|
|
||||||
|
|
||||||
### 条件判断
|
|
||||||
|
|
||||||
```cs
|
|
||||||
int j = 10;
|
|
||||||
if (j == 10) {
|
|
||||||
Console.WriteLine("I get printed");
|
|
||||||
} else if (j > 10) {
|
|
||||||
Console.WriteLine("I don't");
|
|
||||||
} else {
|
|
||||||
Console.WriteLine("I also don't");
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 数组
|
|
||||||
|
|
||||||
```cs
|
|
||||||
char[] chars = new char[10];
|
|
||||||
chars[0] = 'a';
|
|
||||||
chars[1] = 'b';
|
|
||||||
string[] letters = {"A", "B", "C"};
|
|
||||||
int[] mylist = {100, 200};
|
|
||||||
bool[] answers = {true, false};
|
|
||||||
```
|
|
||||||
|
|
||||||
### 循环
|
### 循环
|
||||||
<!--rehype:wrap-class=col-span-2-->
|
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
int[] numbers = {1, 2, 3, 4, 5};
|
int[] numbers = {1, 2, 3, 4, 5};
|
||||||
@ -169,6 +159,17 @@ do
|
|||||||
} while( true );
|
} while( true );
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 数组
|
||||||
|
|
||||||
|
```cs
|
||||||
|
char[] chars = new char[10];
|
||||||
|
chars[0] = 'a';
|
||||||
|
chars[1] = 'b';
|
||||||
|
string[] letters = {"A", "B", "C"};
|
||||||
|
int[] mylist = {100, 200};
|
||||||
|
bool[] answers = {true, false};
|
||||||
|
```
|
||||||
|
|
||||||
C# 数据类型
|
C# 数据类型
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user