gpt4 book ai didi

c# - 日志记录的扩展方法。一个好主意?

转载 作者:行者123 更新时间:2023-11-30 13:11:39 25 4
gpt4 key购买 nike

<分区>

在您看来,以下扩展方法的优缺点是什么?

static class Log
{
public static string AddToLog(this string input)
{
Console.WriteLine(input);
return input;
}

public static string AddToLog(this string input, string format)
{
Console.WriteLine(format, input);
return input;
}
}

使用场景:

class Program
{
static void Main(string[] args)
{
string tableName = "Bills".AddToLog("Default table name is {0}");

"Starting...".AddToLog();
"Creating table".AddToLog();
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com