我正在使用Visual Studio 2008 Pro创建VB Winform应用程序.我的app.config文件中有一些自定义配置设置以及MS SQL连接字符串.
谢谢!
我在将字符串转换为我需要的日期格式时遇到问题.我试图转换的字符串的一个例子是215056081909.我想将该字符串转换为08/19/09 21:50:56.
下面列出的代码是我尝试用于转换过程的代码.当我运行代码时,我收到下面的错误,我很确定这是因为我的字符串在军事(24小时)时间内有时间部分.任何人都可以帮我把字符串转换成我需要的格式吗?
谢谢!
Error:
System.ArgumentOutOfRangeException was unhandled
Message="Index and length must refer to a location within the string. Parameter name: length"
ParamName="length"
Source="mscorlib"
StackTrace:
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at GLTracker.PortManager.DoDataCollection(MessageType type, String msg)
at GLTracker.PortManager.comPort_DataReceived(Object sender, SerialDataReceivedEventArgs e)
at System.IO.Ports.SerialPort.CatchReceivedEvents(Object src, SerialDataReceivedEventArgs e)
at System.IO.Ports.SerialStream.EventLoopRunner.CallReceiveEvents(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, …Run Code Online (Sandbox Code Playgroud)