A Method of Generating Random ArrayList from C
- 2021-07-03 00:45:11
- OfStack
This paper illustrates the method of generating random ArrayList by C #. Share it for your reference. The specific implementation method is as follows:
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);
}
}
I hope this article is helpful to everyone's C # programming.