none
Need help with array. Small Basic RRS feed

  • Question

  • I have 60 names from a file in a array and I need to just display 10 random names.

    • Edited by vill3m Sunday, September 18, 2016 3:16 PM
    Sunday, September 18, 2016 3:00 PM

Answers

  • In Small Basic you can use Math.GetRandomNumber() to do this:

    For i = 1 To 10
      rnd = Math.GetRandomNumber(60)
      TextWindow.WriteLine(yourarray[rnd])
    EndFor

    • Marked as answer by vill3m Sunday, September 18, 2016 3:39 PM
    Sunday, September 18, 2016 3:38 PM

All replies

  • Hi,

    You can achieve this using rand() method and LINQ. Below is C# code snippet to achieve the same.

    YourList.OrderBy(x => rnd.Next()).Take(10)

    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    Sunday, September 18, 2016 3:11 PM
  • I forgot to say that it's small basic
    Sunday, September 18, 2016 3:23 PM
  • In Small Basic you can use Math.GetRandomNumber() to do this:

    For i = 1 To 10
      rnd = Math.GetRandomNumber(60)
      TextWindow.WriteLine(yourarray[rnd])
    EndFor

    • Marked as answer by vill3m Sunday, September 18, 2016 3:39 PM
    Sunday, September 18, 2016 3:38 PM
  • ty dude
    Sunday, September 18, 2016 3:39 PM