Answers for "how to do random.choice in c#"

C#
1

c# random choice

using System;
using System.Collections.Generic;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         var random = new Random();
         var list = new List<string>{ "one","two","three","four"};
         int index = random.Next(list.Count);
         Console.WriteLine(list[index]);
      }
   }
}
Posted by: Guest on November-14-2020
0

c# random choice

static Random rnd = new Random();
Posted by: Guest on March-27-2022

C# Answers by Framework

Browse Popular Code Answers by Language