C# Shuffle a List – Programming, Pseudocode Example, C# Programming Example
Collection Linq Loops / Iteration Statement

C# Shuffle a List

In the following examples you will find more than one solution to mix a list.  Some samples were taken directly from the internet addresses. And You can use the following codes for to shuffle numbers, strings and object.

Note: The internet adresses were added at the end of the article.

Solution 1: Solving the problem in the same class with for statement.

 

Solution 2: Shuffing using by Linq

 

Solution 3: C# Shuffle List of Objects

Student Class

Main Method: Shuffle with Linq

 

Solution 4 : Create an extension method and shuffle by itself (*)

1- Add new class for extetions

2- Add Shuffle method into MyExtentions class as following.

3-Usage in Main method

 

 

 

Source:

  • (*)https://stackoverflow.com/questions/273313/randomize-a-listt

 

 

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.