재우니의 블로그

 

A Simple Way to Shuffle Your Lists in C#

 

C# 으로 Lists 를 간단한 방법으로 Shuffle  순서 섞어보기

 

목록에서 약간의 무작위성이 필요한 적이 있을 경우 목록을 섞는 간단한 방법을 Guid() 함수를 통해 간단하게 사용이 가능합니다. 목록이 상당히 많은 경우에는 성능이슈가 존재합니다. 약간의 목록 개수를 랜덤으로 순서를 변경할땐 좋은 함수 있습니다.

 

var shuffledcards = cards.OrderBy(a => Guid.NewGuid()).ToList();

 

stackoverflow.com/a/4262134

 

Randomize a List

What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type

stackoverflow.com

 

좀 더 알고자 하시는 분들은 아래 stackoverflow 에서 확인해 보시기 바랍니다.

 

https://stackoverflow.com/questions/273313/randomize-a-listt

 

Randomize a List

What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type

stackoverflow.com