美文网首页
C#生成随机ArrayList的代码

C#生成随机ArrayList的代码

作者: 地主天敌 | 来源:发表于2019-01-17 13:02 被阅读0次

将代码过程中比较重要的一些代码备份一次,如下的代码内容是关于C#生成随机ArrayList的代码,应该能对小伙伴们也有好处。

public static void RandomizeArrayList(ArrayList arrayList, Random random) {

    if(arrayList == null) { return; }

    int count = arrayList.Count;

    for(int i=0;i<count;i++) {

      Object tmp = arrayList[i];

      arrayList.RemoveAt(i);

      arrayList.Insert(random.Next(count), tmp);

    }

}

相关文章

网友评论

      本文标题:C#生成随机ArrayList的代码

      本文链接:https://www.haomeiwen.com/subject/xaqidqtx.html