从DateTime获取日期使用C# [英] Get day from DateTime using C#

查看:177
本文介绍了从DateTime获取日期使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

愚蠢的问题给定日期时间的日期,我知道这是星期二例如我如何知道它的tue = 2和mon = 1等...



谢谢

解决方案

您正在寻找 DayOfWeek 属性。

那么,正如Dan在下面的注释中所提到的那样,只需要看一下枚举的整数值来获取整数的日期:

  int d =(int)System.DateTime.Now.DayOfWeek 
pre>

Silly question. Given a date in a datetime and I know it's tuesday for instance how do i know its tue=2 and mon=1 etc...

Thanks

解决方案

You are looking for the DayOfWeek property.
Then, as Dan suggests in the comment below, just look at the integer value of the enum to get the day as integer:

int d = (int)System.DateTime.Now.DayOfWeek

这篇关于从DateTime获取日期使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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