Initial Obsidian notes backup
This commit is contained in:
+23
-3
@@ -13,10 +13,30 @@
|
||||
在函数传参时,两边都要加上修饰词
|
||||
ref:
|
||||
```Csharp
|
||||
static void ChangeValue(ref value)
|
||||
ChangeValue(ref a);
|
||||
//交换数字
|
||||
void Swap(ref int a, ref int b)
|
||||
{
|
||||
int temp = a; a = b; b = temp;
|
||||
}
|
||||
```
|
||||
out:
|
||||
```Csharp
|
||||
//最经典:int.TryParse
|
||||
if (int.TryParse(Console.ReadLine(), out int value))
|
||||
Console.WriteLine(value % 2 == 0 ? "even" : "odd");
|
||||
//int.TryParse伪代码
|
||||
//bool ReadConfig(string key, out string value)
|
||||
//{
|
||||
// if (配置存在)
|
||||
// {
|
||||
// value = 读取到的值; return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// value = null; return false;
|
||||
// }
|
||||
//}
|
||||
```
|
||||
|
||||
案例:
|
||||
原型在[[值类型和引用类型]]笔记中
|
||||
|
||||
|
||||
Reference in New Issue
Block a user