Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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]);
      }
   }
}
Comment

c# random choice


static Random rnd = new Random();

Comment

PREVIOUS NEXT
Code Example
Csharp :: c# how to output in between 0 - 100 in an int array 
Csharp :: convert bytes to string and back c# 
Csharp :: add items to listbox from text file c# 
Csharp :: how to find avareage of an array in c# 
Csharp :: unity c# class addition syntax 
Csharp :: snx disconnect linux 
Csharp :: c# check if string is directory 
Csharp :: listview disable resize columns 
Csharp :: animations for pause menu 
Csharp :: Arrange array element in right and left order starting from least element 
Csharp :: unity camera follow 
Csharp :: c # c^b 
Csharp :: how to add a delay in csharp 
Csharp :: get web config key value in c# razor view 
Csharp :: unity bullet script 
Csharp :: C# delete last enviroment new line 
Csharp :: unity set sprite transparency 
Csharp :: how to remove last 3 characters from string in c# 
Csharp :: time.timescale 
Csharp :: unity read from text file 
Csharp :: unity remove parent 
Csharp :: regex c# password numbers and letters 
Csharp :: c# shuffle array 
Csharp :: dart extending list 
Csharp :: button not working unity 
Csharp :: get name of project c# .net 
Csharp :: c# datetime to timestamp 
Csharp :: c# for loop increment by 2 
Csharp :: how to move towards an object unity 
Csharp :: json.net deserialize dynamic 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =