49路末班车

关注

Index was outside the bounds of the array.

49路末班车

关注

阅读 47

2022-07-27


背景今天写了这么一个函数:


private string DateFormatConversion(string str)
{
string year = "";
char[] pstr = str.ToCharArray();
for (int k = 0; k < 4; k++)
{
year += pstr[k];
}
return year;
}






解决方案:



在处理str之前,先判断str.Length是否大于零

相关推荐

快乐与微笑的淘气

array[index] &= ~PACKET

快乐与微笑的淘气 40 0 0

先峰老师

Write a program to remove duplicates from a sorted array.

先峰老师 39 0 0

何晓杰Dev

python array 的 index

何晓杰Dev 61 0 0

星巢文化

IndexError: index 53 is out of bounds for axis 0 with size 52

星巢文化 234 0 0

花明

The property '***' is not a String or Byte array. Length can only be configured for String and By...

花明 53 0 0

大明宫

解决:IndexError: index 13 is out of bounds for dimension 0 with size 13

大明宫 92 0 0

90哦吼

LeetCode-Peak Index in a Mountain Array

90哦吼 53 0 0

Android开发指南

问题|java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 @Java

Android开发指南 103 0 0

流计算Alink

np.expand_dims: AxisError: axis 4 is out of bounds for array of dimension 4

流计算Alink 38 0 0

丹柯yx

新数组方法:array.at(index)

丹柯yx 93 0 0

精彩评论(0)

0 0 举报