如何编写程序来计算特定日期的日期?在c#中 [英] how can i code a program to calculate the day of a specific date? in c#
本文介绍了如何编写程序来计算特定日期的日期?在c#中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想建立一个程序,我输入日期,然后它返回特定日期的那一天。
我该怎么做?
i wannna build a program where i type the date, and it returns me the day of that specific date.
how can i do that?
推荐答案
查看 DateTime.DayOfWeek
属性。
真的:
Really :
var day = DateTime.Parse("2013/2/11").DayOfWeek; // gives you monday
使用 DateTime.Parse [ ^ ], DateTime.ParseExact [ ^ ], DateTime.TryParse [ ^ ]或 DateTime.TryParseExact [ ^ ]解析给定日期的方法。
然后,您可以使用DateTime.Day
或DateTime.DayOfWeek
属性以获取该特定日期的日期。
Hi,
Use the DateTime.Parse[^], the DateTime.ParseExact[^], the DateTime.TryParse[^] or the DateTime.TryParseExact[^] method to parse the given date.
Then, you can use theDateTime.Day
or theDateTime.DayOfWeek
property to get the day of that specific date.
这篇关于如何编写程序来计算特定日期的日期?在c#中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文