.NET 2.0 DateTime转换错误?? [英] .NET 2.0 DateTime conversion error??

查看:77
本文介绍了.NET 2.0 DateTime转换错误??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试做一些简单的事情。将字符串日期转换为日期时间,但是它没有工作,并且给我一个莫名其妙的错误!


System.Convert.ToDateTime(" Jan 30, 2006)

''System.Convert.ToDateTime(" 1月30日,2006年)''抛出类型的异常

''System.IndexOutOfRangeException''

base {System.SystemException}:{" Index超出了

数组的范围。"}


系统.Convert.ToDateTime(" 01/01 / 2006")

''System.Convert.ToDateTime(" 01/01 / 2006")''引发了类型
的异常
''System.IndexOutOfRangeException''

base {System.SystemException}:{" Index超出了

数组的范围。"}

System.Convert.ToDateTime(fParams.dtStartDate.Valu e)


嗯?它在谈论什么阵列?我已经在.NET 1.1

中多次这样做了,它运行得很好。这是我从.NET转换的项目

1.1。转换是成功的,它编译没有错误,所以

是怎么回事?


请帮忙,完全不知所措。

Tim

Hi,

I am trying to do something simple. Convert a string date to datetime but it
is not working and is giving me a baffling error!

System.Convert.ToDateTime("Jan 30, 2006")
''System.Convert.ToDateTime("Jan 30, 2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}

System.Convert.ToDateTime("01/01/2006")
''System.Convert.ToDateTime("01/01/2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}
System.Convert.ToDateTime(fParams.dtStartDate.Valu e)

Huh? What array is it talking about? I have done this many times in .NET 1.1
and it works just fine. This is a project that I have converted from .NET
1.1. The conversion was successful and it compiles with no errors, so what
is going on?

Please help, completely baffled.

Tim


推荐答案

2006年1月30日星期一19:13:30 -0500," ;添" < ti ****** @ sympatico.ca>

写道:
On Mon, 30 Jan 2006 19:13:30 -0500, "Tim" <ti******@sympatico.ca>
wrote:


我想做一些简单的事。将字符串日期转换为日期时间但它没有工作,并且给我一个莫名其妙的错误!

System.Convert.ToDateTime(" 1月30,2006")
' 'System.Convert.ToDateTime(" 1月30日,2006年)''抛出类型的异常
''System.IndexOutOfRangeException''
base {System.SystemException}:{"索引在外面
数组的界限。}

System.Convert.ToDateTime(" 01/01 / 2006")
''System.Convert.ToDateTime(" 01/01/2006")''抛出类型的异常
''System.IndexOutOfRangeException''
base {System.SystemException}:{"索引超出了
的范围数组。"}
System.Convert.ToDateTime(fParams.dtStartDate.Val ue)

嗯?它在谈论什么阵列?我已经在.NET 1.1中多次这样做了,它运行得很好。这是我从.NET转换的项目
1.1。转换是成功的,它编译没有错误,所以
正在发生什么?

请帮忙,完全不知所措。

Tim
Hi,

I am trying to do something simple. Convert a string date to datetime but it
is not working and is giving me a baffling error!

System.Convert.ToDateTime("Jan 30, 2006")
''System.Convert.ToDateTime("Jan 30, 2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}

System.Convert.ToDateTime("01/01/2006")
''System.Convert.ToDateTime("01/01/2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}
System.Convert.ToDateTime(fParams.dtStartDate.Val ue)

Huh? What array is it talking about? I have done this many times in .NET 1.1
and it works just fine. This is a project that I have converted from .NET
1.1. The conversion was successful and it compiles with no errors, so what
is going on?

Please help, completely baffled.

Tim




试试这个:


DateTime dt = DateTime.Parse(" 01/01 / 2006");

DateTime dte = DateTime.Parse(" Jan 30,2006");

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com


您好奥的斯,


感谢您的回复但是我的系统也失败了。


DateTime.Parse(" 01/01 / 2006")

''DateTime.Parse(" 01/01/2006")''抛出类型的异常

''System.IndexOutOfRangeException''

base {System.SystemException}:{"索引在外面

数组的范围。&qu ot;}


该死的阵列就不会消失!还有更多想法吗?


Tim


Otis Mukinfus" < pH值*** @ emailaddress.com>在消息中写道

news:m9 ******************************** @ 4ax.com ...
Hi Otis,

Thanks for the reply, however this also fails on my system.

DateTime.Parse("01/01/2006")
''DateTime.Parse("01/01/2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}

That damn array just won''t go away! Any more ideas?

Tim

Otis Mukinfus" <ph***@emailaddress.com> wrote in message
news:m9********************************@4ax.com...
On Mon,2006年1月30日19:13:30 -0500,Tim < ti ****** @ sympatico.ca>
写道:
On Mon, 30 Jan 2006 19:13:30 -0500, "Tim" <ti******@sympatico.ca>
wrote:


我正在尝试做一些简单的事情。将字符串日期转换为日期时间,但

不起作用,并给我一个莫名其妙的错误!

System.Convert.ToDateTime(" Jan 30,2006")< br'Scystem.Convert.ToDateTime("Jan 30,2006")''抛出类型的异常
''System.IndexOutOfRangeException''
base {System.SystemException}:{" ;索引超出了
数组的范围。}

System.Convert.ToDateTime(" 01/01 / 2006")
''System.Convert。 ToDateTime(01/01/2006)''抛出类型的异常
''System.IndexOutOfRangeException''
base {System.SystemException}:{" Index超出了界限
数组。"}
System.Convert.ToDateTime(fParams.dtStartDate.Va lue)

嗯?它在谈论什么阵列?我已经在.NET中多次这样做了
1.1
它工作得很好。这是我从.NET转换的项目
1.1。转换是成功的,它编译没有错误,所以
正在发生什么?

请帮忙,完全不知所措。

Tim
Hi,

I am trying to do something simple. Convert a string date to datetime but
it
is not working and is giving me a baffling error!

System.Convert.ToDateTime("Jan 30, 2006")
''System.Convert.ToDateTime("Jan 30, 2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}

System.Convert.ToDateTime("01/01/2006")
''System.Convert.ToDateTime("01/01/2006")'' threw an exception of type
''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the
array."}
System.Convert.ToDateTime(fParams.dtStartDate.Va lue)

Huh? What array is it talking about? I have done this many times in .NET
1.1
and it works just fine. This is a project that I have converted from .NET
1.1. The conversion was successful and it compiles with no errors, so what
is going on?

Please help, completely baffled.

Tim



试试这个:

DateTime dt = DateTime.Parse(" 01/01 / 2006");
DateTime dte = DateTime.Parse(" ; 2006年1月30日");

Otis Mukinfus
http: //www.otismukinfus.com
http://www.tomchilders.com





" Tim" < TI ****** @ sympatico.ca>在留言新闻中写道:v1 ******************* @ news20.bellglobal.com ..。

"Tim" <ti******@sympatico.ca> wrote in message news:v1*******************@news20.bellglobal.com.. .
嗨奥的斯,
<感谢您的回复,但是我的系统也失败了。

DateTime.Parse(" 01/01 / 2006")
''DateTime.Parse(" 01 / 01/2006")''抛出类型''System.IndexOutOfRangeException''的例外基础{System.SystemException}:{"索引超出了数组的范围。}

那该死的阵列就不会消失!还有更多想法吗?
Hi Otis,

Thanks for the reply, however this also fails on my system.

DateTime.Parse("01/01/2006")
''DateTime.Parse("01/01/2006")'' threw an exception of type ''System.IndexOutOfRangeException''
base {System.SystemException}: {"Index was outside the bounds of the array."}

That damn array just won''t go away! Any more ideas?




可能因为那个DAMN ARRAY是真正的问题。

我怀疑日期转换不是你的原因问题。

在调试中放入一些显示器或逐步完成。

找到问题的真正原因


希望这会有所帮助

Bill



Possibly because THAT DAMN ARRAY is the real problem.
I suspect that the Date conversion is NOT the cause of your problem.
Put some displays in or step through in debug.
Find the real cause of your problem

Hope this helps
Bill


这篇关于.NET 2.0 DateTime转换错误??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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