Index was outside the bounds of the array.
来源:互联网 发布:供应链 saas软件 编辑:程序博客网 时间:2024/05/25 08:14
背景今天写了这么一个函数:
private string DateFormatConversion(string str) { string year = ""; char[] pstr = str.ToCharArray(); for (int k = 0; k < 4; k++) { year += pstr[k]; } return year; }
当str传入值如空的时候,就会提示“Index was outside the bounds of the array.”错误。
解决方案:
在处理str之前,先判断str.Length是否大于零
0 0
- Index was outside the bounds of the array.错误解决
- Index was outside the bounds of the array.
- SQL Azure Index was outside the bounds of the array Microsoft.SqlServer.Smo
- 二维码 ThoughtWorks.QRCode 之 index was outside bounds of the array
- .NET Web Deployment Project 编译错误An error occurred when merging assemblies: Index was outside the bounds of the array解决办法
- unity各种报错之:Mesh.colors is out of bounds. The supplied array needs ...
- weiphp 2.0:Your requested sheet index: 1 is out of bounds. The actual number of sheets is 0
- Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: startIndex
- Given an array of non-negative integers, you are initially positioned at the first index of the arra
- Return code of 127 for check of host 'test1' was out of bounds. Make sure the plugin you're trying t
- ArgumentException: Index out of bounds
- Check the valid wavefront array index
- Allegro:Arc segment is outside of the extents.
- Allegro:Arc segment is outside of the extents.
- Allegro:Arc segment is outside of the extents.
- Allegro:Arc segment is outside of the extents.
- delete the element of array
- Why the address of array equals array.
- 在GridControl上显示与表A某字段对应的表B字段
- 2013.11.18周例会小结
- C# string格式的日期时间字符串转为DateTime类型
- TeamViewer软件
- Ora-00911:无效字符
- Index was outside the bounds of the array.
- C#,int转成string,string转成int
- 使用Firefly同步项目Dll问题
- VS2010 切换到设计界面无响应
- VS2010 优化运行速度
- VS2010创建WebService程序
- WebService中更新函数传入值,再调用其中函数时,函数的参数还是未改变
- Custom tool error: Failed to generate code for the service reference ××××××. Please check other erro
- mstsc /admin