无法理解.Net中的日期时间相关代码 [英] Unable to understand Datetime related code in .Net
本文介绍了无法理解.Net中的日期时间相关代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码写在一个页面的页面加载,我无法理解它..
有人可以解释一下..代码是:
DateTime LastDateOfPreviousMonth;
LastDateOfPreviousMonth = Convert.ToDateTime(DateTime.Now.AddDays(( - 1)* DateTime.Now.Day).ToShortDateString());
txtStartDate.Value = new DateTime(LastDateOfPreviousMonth.Year,LastDateOfPreviousMonth.Month, 1 )。ToString( MM / dd / yyyy);
txtEndDate.Value = LastDateOfPreviousMonth.ToShortDateString();
它显示了Startdate和enddate文本框中的日期。
我是.net的新手..请帮助..!
解决方案
这看起来非常像家庭作业。如果是,我建议你们两个:
- 使用调试器,看看每一步发生了什么
- 有一个查看这些方法的文档
- DateTime.AddDays方法 [ ^ ]
I have a code written on the page load of a page and i am not able to understand it..
can somebody please explain me that.. code is:
DateTime LastDateOfPreviousMonth;
LastDateOfPreviousMonth = Convert.ToDateTime(DateTime.Now.AddDays((-1) * DateTime.Now.Day).ToShortDateString());
txtStartDate.Value = new DateTime(LastDateOfPreviousMonth.Year, LastDateOfPreviousMonth.Month, 1).ToString("MM/dd/yyyy");
txtEndDate.Value = LastDateOfPreviousMonth.ToShortDateString();
It shows which dates in Startdate and enddate textbox.
I am new to .net.. Please help..!
解决方案
This looks awfully like a homework. If true, I suggest that you both:
- use the debugger and see what happens in each step
- have a look at the documentation for these methods
这篇关于无法理解.Net中的日期时间相关代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文