public List<T> GetRandomList<T>(List<T> inputList)
{
//Copy to a array
T[] copyArray = new T[inputList.Count];
inputList.CopyTo(copyArray);

//Add range
List<T> copyList = new List<T>();
copyList.AddRange(copyArray);

//Set outputList and random
List<T> outputList = new List<T>();
Random rd = new Random(DateTime.Now.Millisecond);

while (copyList.Count > 0)
{
//Select an index and item
int rdIndex = rd.Next(0, copyList.Count - 1);
T remove = copyList[rdIndex];

//remove it from copyList and add it to output
copyList.Remove(remove);
outputList.Add(remove);
}
return outputList;
}

最新文章

  1. CC2540重写按键
  2. 关于新书《修炼之道:.NET开发要点精讲》的各种说明
  3. 第二十一篇:SOUI中的控件注册机制
  4. 改ucosii的中断禁止和恢复代码,这是一个荒谬的错误【 mrs msr】
  5. promise/bluebird源码
  6. h5audio标签
  7. VSCode配置eslint
  8. [SDOI 2013]方程
  9. [转]Understanding OpenStack Authentication: Keystone PKI
  10. 熬之滴水成石:最想深入了解的内容--windows内核机制(6)
  11. 我和struts2 的第一天
  12. A “Type Erasure” Pattern that Works in Swift:类型域的转换
  13. java反射bean to bean
  14. Application HookMainWindow
  15. Fragment----静态创建碎片
  16. (五)动态SQL
  17. hdu 4435 第37届ACM/ICPC天津现场赛E题
  18. 撤销正在审核的app
  19. HDU 3435 A new Graph Game(最小费用最大流)&amp;amp;HDU 3488
  20. 工作中遇到的令人头疼的bug

热门文章

  1. C#使用var定义变量时的四个特点
  2. HTTP协议相关介绍
  3. Action Results in MVC
  4. 编写javascript的基本技巧一
  5. 20169219 NMap+Wireshark实验报告
  6. MongoDB整理笔记のSharding分片
  7. .net core webapi 文件上传在 Swagger 文档中的有好提示处理
  8. 警惕C#事件使用过程中的GC陷阱
  9. C# 高斯消元项目运用
  10. C#质因子(自己别扭的逻辑。。)