/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/programming-guide/language-features/arrays/split2.vb
25 строк
855 B
Andy De George
Move snippets from samples repo to this repo (#17296)
03 мар 2020, 19:23
Не верифицирован
03 мар 2020, 19:23
dbbeda1
Код
Авторство
О чём код?
Module Example Public Sub Main() Dim rnd As New Random() ' Create an array of 100 elements. Dim arr(99) As String ' Populate each element with an arbitrary ASCII character. For ctr = 0 To arr.GetUpperBound(0) arr(ctr) = ChrW(Rnd.Next(&h21, &h7F)) Next ' Get a random number that will represent the point to insert the delimiter. arr(rnd.Next(0, arr.GetUpperBound(0))) = "zzz" ' Find the delimiter. Dim location = Array.FindIndex(arr, Function(x) x = "zzz") ' Create the arrays. Dim arr1(location - 1) As String Dim arr2(arr.GetUpperBound(0) - location - 1) As String ' Populate the two arrays. Array.Copy(arr, 0, arr1, 0, location) Array.Copy(arr, location + 1, arr2, 0, arr.GetUpperBound(0) - location) End Sub End Module