add
yirongjin
2025-07-24 b9c933a1a9c9de300ed8b10d07d482216c387323
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace iWareCommon.Utils
{
    /// <summary>
    /// LIST帮助类 
    /// </summary>
    public class ListHelper
    {
        /// <summary>
        /// LIST打乱顺序
        /// </summary>
        /// <param name="oldList">要处理的LIST</param>
        /// <returns>打乱顺序后的LIST</returns>
        public static List<T> RandomList<T>(List<T> oldList)
        {
            Random r = new Random(Guid.NewGuid().GetHashCode());
            List<T> newList = new List<T>();
            foreach (var item in oldList)
            {
                newList.Insert(r.Next(newList.Count), item);
            }
            return newList;
        }
    }
}