List<string> lstSample = new List<string>(); Random rand = new Random(); List<int> lstRand = new List<int>(); for (int i = 0; lstRand.Count() < sampleNum; i++) { int mRandNum = rand.Next(0, mStageDataCount); if (!lstRand.Contains(mRandNum)) { lstRand.Add(mRandNum); lstSample.Add(lstDataAll.ToList()[mRandNum]); } }
原文地址:https://www.cnblogs.com/love201314/p/8489398.html
时间: 2024-09-30 23:58:15