Answers for "using .random in a loop c#"

C#
11

generate a random number in c#

Random rnd = new Random();
int value = rnd.Next(min,max);
Console.Write(value);
Posted by: Guest on July-15-2020
1

how to pick a random item in c#

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

C# Answers by Framework

Browse Popular Code Answers by Language