开发者

C# Sorting objects multiple keys

开发者 https://www.devze.com 2023-03-17 16:53 出处:网络
I am developing an app for WP7. I pull some data out of a Sterling Database and put in into my own objects.These objects I am deriving a date attribute and setting that - it has a time already (that h

I am developing an app for WP7. I pull some data out of a Sterling Database and put in into my own objects. These objects I am deriving a date attribute and setting that - it has a time already (that has been he开发者_开发百科ld on the object in the Sterling database).

I then want to sort these objects by date and time before presenting them. Currently Date and time are separate String fields but I can combine them into a DateTime attribute if I want.

Is there a recommended way of doing this. I have seen several options.. but not sure what is the best approach.

Any advice appreciated here. - thanks


If you combine into a DateTime it makes your code a lot smaller. The reason for this is that DateTime supports comaprison operators such as <, >, ==, etc. That way you can just say (time1 < time2) or whatever your comparison function does.

0

精彩评论

暂无评论...
验证码 换一张
取 消