我想當前的日期返回到我的事件記錄器,我已經試過這樣:Datetime.utc返回1-1-0001 00:00:00在事件查看器
public class LogDate
{
protected DateTime localDate { get; set; }
public LogDate()
{
localDate = DateTime.Now;
}
}
。
public class Eventlog : LogDate
{
public void logEvent(string answer)
{
this.localDate = new DateTime();
try
{
string sSource;
string sLog;
string sEvent;
sSource = "dotNET Sample App";
sLog = "filmdatabase";
sEvent = this.localDate + answer;
不知何故,當我嘗試這個,它返回1-1-0001 00:00:00。而不是實際的時間。
順便說一句,有沒有'DateTime.UtcNow'在你的代碼。 –