Random
-
[.NET] List 배열을 Random 정렬하는 간단한 소스코드 예시.NET/개념 및 유용한 팁 2021. 2. 12. 11:47
개인프로젝트 진행하다가 .NET에서 코드 1줄로 랜덤 정렬 구현하는 방법을 정리할 겸 작성. using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace RandomArrayTest { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); List list = new List() { 1,2,3,4,5,6,7,8,9,10 }; // 랜덤으로 정렬시킬 List (어떤 유형이건 상관없음) list.Sort((a, b) => new Random().NextDouble() >= 0.5? 1 : -1); /..