在C#中表示时间对象的最佳做法是什么? [英] What's best practice to represent a Time object in C#?

查看:120
本文介绍了在C#中表示时间对象的最佳做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库表中有一个时间列。日期并不重要,我们只是想要一天的时间。什么类型最好在C#中表示它?我要使用一个DateTime,但是我不喜欢这个日期的想法。

解决方案

你可以使用 TimeSpan 结构来表示.NET中的一个时间。


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 DateTime, but I don't like the idea of having a date.

解决方案

You could use a TimeSpan structure to represent a time in .NET.

这篇关于在C#中表示时间对象的最佳做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆