“Dapatkan nomor acak unik di vb.net” Kode Jawaban

Dapatkan nomor acak unik di vb.net

Dim numbers = Enumerable.Range(0, 11).ToList()
Dim RandomClass As New Random()
Dim RandomIndex As Integer
For counter As Integer = 1 To 5
    RandomIndex = RandomClass.Next(0, numbers.Count)
    MsgBox(numbers(RandomIndex))
    numbers.RemoveAt(RandomIndex)
Next
Shy Stoat

Dapatkan nomor acak unik di vb.net

Dim RandomClass As New Random()
Dim RememberSet As New HashSet(Of Integer)

Dim RandomNumber As Integer

While RememberSet.Count < 5
    RandomNumber = RandomClass.Next(0, 10)
    If RememberSet.Add(RandomNumber) Then
        MsgBox(RandomNumber)
    End If
End While
Shy Stoat

Jawaban yang mirip dengan “Dapatkan nomor acak unik di vb.net”

Pertanyaan yang mirip dengan “Dapatkan nomor acak unik di vb.net”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya