System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string

前端 未结 5 2028
野趣味
野趣味 2020-12-18 03:25

I have this code. I am trying to retrieve just the text \"first program\". Considering that i know the index say 25 and total length of string is 35.

string          


        
5条回答
  •  太阳男子
    2020-12-18 04:26

    The second parameter to Substring is how long you want the substring to be, not the end point of the substring. 25 + 35 is outside the range of the original string, so it throws an exception.

提交回复
热议问题