2012/11/10工作总结——潘学

今天,只是在昨天的基础上进行的,昨天处理了对数据库模块的访问,和输出特定值。今天只是在另一个地再次输出罢了。

今天处理是首页左面,对随机类型问题的显示问题。

随机处理:

private static int Chaos_GetRandomSeed()  //我们可以采用加密随机数生成器来生成不同的种子,每次需要生成随机数的时候为Random赋予不同的种子,即使在很短的时间内也可以保证生成的随机数不同。     {

        byte[] bytes = new byte[4];

        System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();

        rng.GetBytes(bytes);

        return BitConverter.ToInt32(bytes, 0);

    }

   int[] iRand = new int[4];
        for (int i = 0; i < 4; i++)
        {
            //每次生成随机数的时候都使用机密随机数生成器来生成种子,
            //这样即使在很短的时间内也可以保证生成的随机数不同
            Random rdm = new Random(Chaos_GetRandomSeed());
            //获取一个10到30之间的随机数
            iRand[i] = rdm.Next(3, QADownloadRank.Count());
        }

 

这里考虑由于随机数是由系统时间给出的,由于CPU的运行速度太快了,可能导致得到的随机数相同,所以每次是新的随即种子。

 

QA显示问题:

Item1.Text = QADownloadRank[iRand[0]].keyWord;         LatestQ1.Text = QADownloadRank[iRand[0]].QDescription;         LatestA1.Text = QADownloadRank[iRand[0]].ADescription;

        Item2.Text = QADownloadRank[iRand[1]].keyWord;         LatestQ2.Text = QADownloadRank[iRand[1]].QDescription;         LatestA2.Text = QADownloadRank[iRand[1]].ADescription;

        Item3.Text = QADownloadRank[iRand[2]].keyWord;         LatestQ3.Text = QADownloadRank[iRand[2]].QDescription;         LatestA3.Text = QADownloadRank[iRand[2]].ADescription;

        Item4.Text = QADownloadRank[iRand[3]].keyWord;         LatestQ4.Text = QADownloadRank[iRand[3]].QDescription;         LatestA4.Text = QADownloadRank[iRand[3]].ADescription;

posted @ 2012-11-10 23:25  DOOM_buaascse  阅读(219)  评论(2编辑  收藏  举报