简体   繁体   中英

how to compare two dates in C# Without comparing the time?

I want to compare two dates in C# i have tried Toshortdate() but its not working for me i dont know why? I just want to compare the dates not the time.. My code is as below:

 Convert.ToDateTime(b.CreatedDate).ToShortDateString() == Convert.ToDateTime(objbreedable.LastBDate).ToShortDateString()

Please help me.

使用Date属性。

Convert.ToDateTime(b.CreatedDate).Date == Convert.ToDateTime(objbreedable.LastBDate).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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM