草庐IT

DATETIME

全部标签

c# - 值的默认参数必须是编译时常量?

这是我的方法签名。在尝试将end作为可选参数传递时,它给了我这个错误。我应该怎么做才能解决这个问题?为什么DateTime.MinValue不是常量?publicstaticvoidDatesToPeriodConverter(DateTimestart,DateTimeend=DateTime.MinValue,outstringdate,outstringtime) 最佳答案 DateTime.MinValue不是const,因为语言不喜欢DateTime上的const。一种选择是使用DateTime?代替,即publicsta

c# - 值的默认参数必须是编译时常量?

这是我的方法签名。在尝试将end作为可选参数传递时,它给了我这个错误。我应该怎么做才能解决这个问题?为什么DateTime.MinValue不是常量?publicstaticvoidDatesToPeriodConverter(DateTimestart,DateTimeend=DateTime.MinValue,outstringdate,outstringtime) 最佳答案 DateTime.MinValue不是const,因为语言不喜欢DateTime上的const。一种选择是使用DateTime?代替,即publicsta

c# - 在 Microsoft Visual Studio 调试器中更改日期时间

什么...。如何在调试器中更改DateTime的值?我可以更改它,但是在离开编辑字段时出现错误;它无法解析它。编辑:VS2008,C# 最佳答案 如果不查看您拥有的内容,我不太确定您指的是哪个编辑字段。但是,您可以尝试使用即时窗口和DateTime.Parse或newDateTime()。 关于c#-在MicrosoftVisualStudio调试器中更改日期时间,我们在StackOverflow上找到一个类似的问题: https://stackoverflo

c# - 在 Microsoft Visual Studio 调试器中更改日期时间

什么...。如何在调试器中更改DateTime的值?我可以更改它,但是在离开编辑字段时出现错误;它无法解析它。编辑:VS2008,C# 最佳答案 如果不查看您拥有的内容,我不太确定您指的是哪个编辑字段。但是,您可以尝试使用即时窗口和DateTime.Parse或newDateTime()。 关于c#-在MicrosoftVisualStudio调试器中更改日期时间,我们在StackOverflow上找到一个类似的问题: https://stackoverflo

c# - DateTime.MinValue 和 SqlDateTime 溢出

我不想验证txtBirthDate,所以我想在数据库中传递DateTime.MinValue。我的代码:if(txtBirthDate.Text==string.Empty)objinfo.BirthDate=DateTime.MinValue;elseobjinfo.BirthDate=DateTime.Parse(txtBirthDate.Text);DateTime.MinValue返回Date={1/1/000112:00:00AM}我收到一个SQL错误:SqlDateTimeoverflow.Mustbebetween1/1/175312:00:00AMand12/31/99

c# - DateTime.MinValue 和 SqlDateTime 溢出

我不想验证txtBirthDate,所以我想在数据库中传递DateTime.MinValue。我的代码:if(txtBirthDate.Text==string.Empty)objinfo.BirthDate=DateTime.MinValue;elseobjinfo.BirthDate=DateTime.Parse(txtBirthDate.Text);DateTime.MinValue返回Date={1/1/000112:00:00AM}我收到一个SQL错误:SqlDateTimeoverflow.Mustbebetween1/1/175312:00:00AMand12/31/99

c# - 以编程方式更改系统日期

如何使用C#以编程方式更改本地系统的日期和时间? 最佳答案 HereiswhereIfoundtheanswer.;我已在此处重新发布它以提高清晰度。定义这个结构:[StructLayout(LayoutKind.Sequential)]publicstructSYSTEMTIME{publicshortwYear;publicshortwMonth;publicshortwDayOfWeek;publicshortwDay;publicshortwHour;publicshortwMinute;publicshortwSecond

c# - 以编程方式更改系统日期

如何使用C#以编程方式更改本地系统的日期和时间? 最佳答案 HereiswhereIfoundtheanswer.;我已在此处重新发布它以提高清晰度。定义这个结构:[StructLayout(LayoutKind.Sequential)]publicstructSYSTEMTIME{publicshortwYear;publicshortwMonth;publicshortwDayOfWeek;publicshortwDay;publicshortwHour;publicshortwMinute;publicshortwSecond

c# - 将日期 yyyyMMdd 转换为 system.datetime 格式

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:howtoconvertdatefromyyyyMMddformattomm-dd-yyyyfomrat我有一个string,其中包含yyyyMMdd格式的日期。我想使用ConvertTo.DateTime()方法或任何其他简单方法将该日期转换为系统日期格式。stringvalue="19851231";//yyyyMMddDateTimedateTime=1985/12/31;

c# - 将日期 yyyyMMdd 转换为 system.datetime 格式

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:howtoconvertdatefromyyyyMMddformattomm-dd-yyyyfomrat我有一个string,其中包含yyyyMMdd格式的日期。我想使用ConvertTo.DateTime()方法或任何其他简单方法将该日期转换为系统日期格式。stringvalue="19851231";//yyyyMMddDateTimedateTime=1985/12/31;