目標 - 找出哪個DateTime更近。比較DateTime對象
我可以算出來,此代碼:
DateTime dt1 = new DateTime(...); //let's say it was created on 1/1/2000
DateTime dt2 = new DateTime(...); //let's say it was create on 1/1/2011
if (dt2.ToBinary() > dt1.ToBinary()) {
print dt2 is newer than dt1 }
我可以簡單地將datetime對象轉換爲二進制,然後假定較大的一個是更近?
感謝, 凱文