当前位置: 首页>>代码示例>>C#>>正文


C# Random.GetHashCode方法代码示例

本文整理汇总了C#中Random.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Random.GetHashCode方法的具体用法?C# Random.GetHashCode怎么用?C# Random.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Random的用法示例。


在下文中一共展示了Random.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Terms.Member.Business.MemberInformation memberInformation = _MemberInformationService.FindMemberInformationByUserName(this.txtEmail.Text.Trim(), 1);

        if (memberInformation == null)
        {
            lblErrorMassage.Visible = true;
            lblErrorMassage.Text = "The e-mail address you provided was not recognized. Please try again.";
            return;
        }

        Random ran = new Random();
        String password = ran.GetHashCode().ToString();

        string strGender = string.Empty;

        if (memberInformation.Gender == 0)
        {
            strGender = "Mr";
        }

        if (memberInformation.Gender == 1)
        {
            strGender = "Mrs";
        }

        if (memberInformation.Gender == 2)
        {
            strGender = "Ms";
        }

        string mailStr = "";
        mailStr += "Dear " + strGender + ". " + memberInformation.FirstName + " " + memberInformation.MiddleName + " " + memberInformation.LastName + "," + "<br><br><br>";
        mailStr += "You have requested a password reminder for your Majestic Vacations account." + "<br><br>";
        mailStr += "As it is impossible for us to retrieve your original password we have generated a new one." + "<br><br>";
        mailStr += "Your new password is <b>" + password + "</b>, please use this when logging in to Majestic Vacations next time. Note that the password is case-sensitive." + "<br>" + "<br>";
        mailStr += "Note that this is an automatically generated e-mail, please do not reply to this e-mail address." + "<br><br><br>";
        mailStr += "Sincerely," + "<br><br>";
        mailStr += "Majestic Vacations Support Team";
        mailStr += "<p>Note that this is an automatically generated e-mail, please do not reply to this e-mail address</p>";

        password = MemberUtility.Lock(password);

        memberInformation.Password = password;

        _MemberInformationService.Update(memberInformation);

        MailMessage mailMessage = new MailMessage();

        mailMessage.IsBodyHtml = true;
        mailMessage.From = new MailAddress(@"[email protected]");
        mailMessage.To.Add(new MailAddress(memberInformation.EmailAddress));

        mailMessage.Subject = "Majestic Vacation your new password";
        mailMessage.Body = mailStr;

        Terms.Member.Utility.MemberUtility.SendEmail(mailMessage, "B2BMembership");

        this.Response.Redirect("~/B2B_SUB/AgentJoinSucceedForm.aspx");
    }
开发者ID:foxvirtuous,项目名称:MVB2C,代码行数:60,代码来源:Forget.aspx.cs

示例2: hy_exam

    public void hy_exam()
    {
        //输出试卷
        HyoaClass.Hyoa_flowmain Hyoa_flowmain = new HyoaClass.Hyoa_flowmain();
        DataTable dt;
        Hyoa_flowmain.hy_mudelid = "zsgl";
        Hyoa_flowmain.hy_tableid = "9b3dd7c5-a4ab-46c5-a1c8-5d7879bdf050";
        dt = Hyoa_flowmain.GetAllflowmainsByTableidAndMudelid();
        string lsexam="";
        this.txtanswer.Text = "";
        string lsfield60;
        string lsupdata;
        //输出N题,题目
        int rndNum;
        string lssumrnd="";
        string lstemp = "";
        int rndmod;
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            while (true)
            {
                Random rnd = new Random();
                rndNum = rnd.GetHashCode();
                rndmod = rndNum % dt.Rows.Count;
                lstemp = "," + rndmod.ToString() + ",";
                if (lssumrnd.IndexOf(lstemp) < 0)
                {
                    if (lssumrnd=="")
                    {
                        lssumrnd = "," + rndmod.ToString() + ",";
                    }
                    else
                    {
                        lssumrnd = lssumrnd + rndmod.ToString() + ",";
                    }
                    break;
                }
            }
            lsexam += "<font color=red>题目" + (i + 1).ToString() + ":</font>" + dt.Rows[rndmod]["hy_field3"].ToString() + "<br />";
            //目前只支持判断题和选择题
            if (dt.Rows[rndmod]["hy_field1"].ToString() == "判断题")
            {
                lsexam += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"对\" />对" + "&nbsp;&nbsp;&nbsp;&nbsp;";
                lsexam += "<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"错\" />错" + "<br />";
                //正确答案
                if (this.txtanswer.Text == "")
                    this.txtanswer.Text = dt.Rows[rndmod]["hy_field2"].ToString();
                else
                    this.txtanswer.Text += "*" + dt.Rows[rndmod]["hy_field2"].ToString();
                //分数
                if (this.txtscore.Text == "")
                    this.txtscore.Text = dt.Rows[rndmod]["hy_field4"].ToString();
                else
                    this.txtscore.Text += "*" + dt.Rows[rndmod]["hy_field4"].ToString();
            }
            else
            {
                if (dt.Rows[rndmod]["hy_field10"].ToString() != "")
                {
                    lsexam += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"A\" />A、" + dt.Rows[rndmod]["hy_field10"].ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;";
                }
                if (dt.Rows[rndmod]["hy_field11"].ToString() != "")
                {
                    lsexam += "<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"B\" />B、" + dt.Rows[rndmod]["hy_field11"].ToString() + "<br />";
                }
                if (dt.Rows[rndmod]["hy_field12"].ToString() != "")
                {
                    lsexam += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"C\" />C、" + dt.Rows[rndmod]["hy_field12"].ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;";
                }
                if (dt.Rows[rndmod]["hy_field13"].ToString() != "")
                {
                    lsexam += "<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"D\" />D、" + dt.Rows[rndmod]["hy_field13"].ToString() + "<br />";
                }
                if (dt.Rows[rndmod]["hy_field14"].ToString() != "")
                {
                    lsexam += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"E\" />E、" + dt.Rows[rndmod]["hy_field14"].ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;";
                }
                if (dt.Rows[rndmod]["hy_field15"].ToString() != "")
                {
                    lsexam += "<input name=\"hy_answer_" + i.ToString() + "\" type=checkbox value=\"F\" />F、" + dt.Rows[rndmod]["hy_field15"].ToString() + "<br />";
                }
                //正确答案
                if (this.txtanswer.Text == "")
                    this.txtanswer.Text = dt.Rows[rndmod]["hy_field2"].ToString();
                else
                    this.txtanswer.Text += "*" + dt.Rows[rndmod]["hy_field2"].ToString();
                //分数
                if (this.txtscore.Text == "")
                    this.txtscore.Text = dt.Rows[rndmod]["hy_field4"].ToString();
                else
                    this.txtscore.Text += "*" + dt.Rows[rndmod]["hy_field4"].ToString();
            }
            lsexam += "<br />";

        }
        this.lbexam.Text = lsexam;
    }
开发者ID:wjszxli,项目名称:Webapp,代码行数:97,代码来源:main_examination.aspx.cs


注:本文中的Random.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。