C# 无奖竞猜第二弹:输出结果是什么?
🏷️ C#
csharp
static void Main(string args)
{
try
{
StringBuilder builder = new StringBuilder("world, ");
AppendHello(ref builder);
Console.WriteLine(builder.ToString());
ClearBuilder(ref builder);
Console.WriteLine(builder.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.ReadLine();
}
}
static void AppendHello(ref StringBuilder builder)
{
builder.Append("hello!");
}
static void ClearBuilder(ref StringBuilder builder)
{
builder = null;
}