What's best practice to represent a Time object in C#?

后端 未结 7 744
情歌与酒
情歌与酒 2020-12-18 19:20

I have a Time column in a database table. The date is not important, we just want a time in the day. What type would be best to represent it in C#? I was going to use a Date

7条回答
  •  萌比男神i
    2020-12-18 19:47

    We actually rolled our own Time class. The issue we ran into is TimeSpan has no knowledge of timezone offsets which we still needed. So We created a TimeSpanOffset class. Kind of analogous to the DateTimeOffset class. If timezone is not important than I would definitely stick with the TimeSpan.

提交回复
热议问题