C# 无奖竞猜:两行 Console.WriteLine
分别输出什么?
🏷️ C#
csharp
static void Main(string args)
{
StringBuilder builder = new StringBuilder("world, ");
AppendHello(builder);
Console.WriteLine(builder.ToString());
ClearBuilder(builder);
Console.WriteLine(builder.ToString());
Console.ReadLine();
}
static void AppendHello(StringBuilder builder)
{
builder.Append("hello!");
}
static void ClearBuilder(StringBuilder builder)
{
builder = null;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
点击查看输出结果
world, hello!
world, hello!