【发布时间】:2011-04-29 17:30:29
【问题描述】:
我得到了一个包含一些时间实用方法的课程。现在我需要添加一个执行以下操作的方法:
public static string LastUpdated(DateTime date)
{
string result = string.Empty;
//check if date is sometime "today" and display it in the form "today, 2 PM"
result = "today, " + date.ToString("t");
//check if date is sometime "yesterday" and display it in the form "yesterday, 10 AM"
result = "yesterday, " + date.ToString("t");
//check if the day is before yesterday and display it in the form "2 days ago"
result = ... etc;
return result;
}
有什么想法吗?
【问题讨论】:
-
看起来你走在了正确的轨道上。是什么阻碍了你?