I made it real simple; I put this line in its own project
System.Convert.ToDateTime("01/01/2006");
and I am still getting
'Index was outside the bounds of the array.' - what array?
These are the details...
System.IndexOutOfRangeException was unhandled
Message="Index was outside the bounds of the array."
Source="mscorlib"
StackTrace:
at
System.Globalization.DateTimeFormatInfo.InsertHash (TokenHashValue[]
hashTable, String str, TokenType tokenType, Int32 tokenValue)
at System.Globalization.DateTimeFormatInfo.CreateToke nHashTable()
at System.Globalization.DateTimeFormatInfo.Tokenize(T okenType
TokenMask, TokenType& tokenType, Int32& tokenValue, __DTString& str)
at System.__DTString.GetSeparatorToken(DateTimeFormat Info dtfi)
at System.DateTimeParse.Lex(DS dps, __DTString& str, DateTimeToken&
dtok, DateTimeRawInfo& raw, DateTimeResult& result, DateTimeFormatInfo&
dtfi)
at System.DateTimeParse.TryParse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles, DateTimeResult& result)
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value)
at TestApp.Form1..ctor() in C:\Documents and Settings\Tim\My
Documents\Visual Studio 2005\Projects\TestApp\TestApp\Form1.cs:line 17
at TestApp.Program.Main() in C:\Documents and Settings\Tim\My
Documents\Visual Studio 2005\Projects\TestApp\TestApp\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
"Tim" <ti*@home.com> wrote in message
news:YS******************@news20.bellglobal.com...
Hi,
The following code works just fine in VS 2003 but in VS 2005 I am getting
an error:
The code:
DateTime dClose = System.Convert.ToDateTime(now.Date.ToString("MMM dd,
yyyy") + " " + storeClose.Hour + ":" + storeClose.Minute);
The error:
threw an exception of type 'System.IndexOutOfRangeException'
base {System.SystemException}: {"Index was outside the bounds of the
array."}
now.Date.ToString("MMM dd, yyyy") gives me "Jan 09, 2006"
storeClose.Hour gives me 17
storeClose.Minute gives me 30
The whole string is "Jan 09, 2006 17:30" which should convert to a date no
problem. Can someone help?
Tim