-2
Не могу понять, какие проблемы с этими кодами?Объявление массивов в подпроцессе
Он продолжает производить:
IndexOutOfRangeException
Module Module1
Sub Main()
Console.WriteLine("Please input the length of the array")
Dim n As Integer = Console.ReadLine()
Dim numbers(n - 1) As Integer
Console.WriteLine("Please inform us the number you want to find")
Dim x As Integer = Console.ReadLine()
For i = 0 To n - 1
Console.WriteLine("Please input the {0} number", i)
numbers(i) = Console.ReadLine()
Next
examining(x, n, numbers(n - 1))
Console.ReadLine()
End Sub
Sub examining(ByVal x As Integer, ByVal n As Integer, ByVal ParamArray numbers() As Integer)
Dim i As Integer
For i = 0 To n - 1
If numbers(i) = x Then
Console.WriteLine("There exists {0} in the array", x)
Exit For
End If
Next
If i = n - 1 Then Console.WriteLine("{0} does not exist in the array", x)
End Sub
End Module
Пожалуйста, измените свой пост и добавить стек исключений трассировки , поэтому мы можем видеть, какая строка вызывает проблему. –
Я не знаю этого языка, но не должен его изучать (x, n, numbers) ', а не' examining (x, n, numbers (n - 1)) '? – melpomene