-1

こんにちは皆さん、日付のみを表示するにはどうすればよいですか。temp.StartDate.Date は機能しません。2012 年 3 月 5 日 12:00:00 と表示されます。

私は試した

temp.StartDate.Date
temp.StartDate
temp.StartDate.ToShortDateString
temp.StartDate.Date.ToShortDateString

これが私のコードです

List<DateTime> dateList = new List<DateTime>();
    foreach(sMedication temp in medicationList) 
    {
        if (dateList.Contains(temp.StartDate.Date))
        {

        }
        else
        {
            dateList.Add((temp.StartDate.Date));

        }
    }
    lstboxSchedule.ItemsSource = date

リスト;

4

2 に答える 2

1

現在のコードは値を変更しますが、表示用に変換しません

したがって、次のようなものは、文字列を表示用に変換します。

List<string> dateList = new List<string>();
foreach(sMedication temp in medicationList) 
{
    if (!dateList.Contains(temp.StartDate.ToShortDateString()))
    {
        dateList.Add((temp.StartDate.ToShortDateString()));
    }
}
lstboxSchedule.ItemsSource = date
于 2012-06-14T08:07:05.833 に答える
0

使ってみて

temp.StartDate.ToString("dd/MM/yyyy");
于 2012-06-14T07:26:23.163 に答える