开发者

Index was outside the bounds of the array

I am getting "Index was outside the bounds of the array." error when using this code:

Dim RandomA As String = "aAÀàÁâÄäÅåĀāĂ㥹ǞǟǺǻÃãÄ"
Tex开发者_运维百科tBox1.Text = TextBox1.Text.Replace("a", RandomA((Int(Rnd() * RandomA.Count)) - 1))

I fail to see how the (random) index can be out of bounds?


Int(Rnd() * RandomA.Count) could return 0, and 0 - 1 is outside the bounds.


it is an edge condition for sure. the equation evaluates to -1 under certain random number conditions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜