关键词搜索

源码搜索 ×
×

Index was outside the bounds of the array.

发布2014-01-08浏览49055次

详情内容

背景今天写了这么一个函数:
  1. private string DateFormatConversion(string str)
  2. {
  3. string year = "";
  4. char[] pstr = str.ToCharArray();
  5. for (int k = 0; k < 4; k++)
  6. {
  7. year += pstr[k];
  8. }
  9. return year;
  10. }
当str传入值如空的时候,就会提示“Index was outside the bounds of the array.”错误。
解决方案:
在处理str之前,先判断str.Length是否大于零

相关技术文章

最新源码

下载排行榜

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载