Answers for "randomize through array in C#"

C#
1

randomize through array in C#

// answer coded by 'mdb' and edited later on by 'Caius Jard'

Random rnd = new Random();
string[] MyRandomArray = MyArray.OrderBy(x => rnd.Next()).ToArray();
Posted by: Guest on September-28-2020
0

randomize through array in C#

using System;
using System.Collections.Generic;

namespace whatever_you_want
{
	public class Randomizer
    {
    	public static T Randomize<T>(List<T> array)
        {
        	Random rnd = new Random();
          	return array[rnd.Next(0, array.Count)];
        }
    }
}
Posted by: Guest on September-28-2020

C# Answers by Framework

Browse Popular Code Answers by Language