方法一:
-
static void TestMethod(DateTime? date = null)
-
{
-
date = date ?? DateTime.Now; //若date有值,date为指定日期值,date为空或者不传此值,date为Now
-
}
感谢:https://www.cnblogs.com/Interkey/p/parameter_datetime_default_value.html
以及:http://www.it1352.com/389780.html
方法二
-
static DateTime TestMethod(DateTime dt = default(DateTime))
-
{
-
return dt;
-
}