1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections.Generic;
- namespace YBEE.EQM.Core;
- /// <summary>
- /// 帮助类
- /// </summary>
- public static class Helper
- {
- /// <summary>
- /// List随机乱序
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="sources"></param>
- public static void ListRandom<T>(List<T> sources)
- {
- Random rd = new();
- int index;
- T temp;
- for (int i = 0; i < sources.Count; i++)
- {
- index = rd.Next(0, sources.Count - 1);
- if (index != i)
- {
- temp = sources[i];
- sources[i] = sources[index];
- sources[index] = temp;
- }
- }
- }
- }
|