How do I remove time portion from DateTime
within Get Set Properties
The below code is not working and I tried a few ways. I also tried dateValue.ToString("d")
private DateTime dateValue;
public DateTime DateValue
{
get
{
//First Try
return dateValue.ToShortDateString;
//Second Try
return dateValue.ToString("d")
//Third Try
DateTime dateValue = DateTime.????(not sure)
}
}
You can use the Date property.
DateTime dateValue = dateValue.Date;
So it would be
private DateTime dateValue;
public DateTime DateValue
{
get
{
return dateValue.Date;
}
}
您正在寻找Date
:
return dateValue.Date;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.