使用C#从日期时间获取的一天 [英] Get day from DateTime using C#

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

问题描述

愚蠢的问题。鉴于日期时间日期和我知道这是周二比如我怎么知道它的星期二= 2和MON = 1等等...

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...

感谢

推荐答案

您正在寻找的 DAYOFWEEK 物业买卖资讯
之后,丹建议在下面的评论,只是看在枚举的整数值,以获得一天的整数:

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

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

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