private static void print(StreamWriter sw, string mlog, bool screen)
{
DateTime ts = DateTime.Now;
sw.WriteLine(ts + " " + mlog);
if (screen == true)
{
Console.WriteLine(mlog);
}
}
我会用print (sw,"write here", false)
来调用。 90%的机会我会使用虚假的。如何使它成为默认情况下是错误的,当我打电话时我不需要额外的类型?C#默认值
有时它最好有明确的方法,例如PrintToStream()和PrintToStreamAndScreen() –