需要加扰选定的文字

时间:2016-03-22 06:11:51

标签: c#

    protected void Button_Upload_Click(object sender, EventArgs e)
    {
        string path = Server.MapPath("~/Data/" + FileUpload1.FileName);
        string[] readtext = File.ReadAllLines(path);
        var a = readtext;
        List<string> strList = new List<string>();
         foreach (string s in readtext)
        {
            strList.Add(s);
        }
        ListBox1.DataSource = strList;
        ListBox1.DataBind();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        var b = ListBox1.SelectedIndex;
        var a = ListBox1.SelectedValue.ToString();
        if (b < 0)
        {
            // no ListBox item selected;
            return;
        }

           StringBuilder jumbleSB = new StringBuilder();
            jumbleSB.Append(a);
            Random rand = new Random();
            int lengthSB = jumbleSB.Length;
            for (int i = 0; i < lengthSB; ++i)
            {
                int index1 = (rand.Next() % lengthSB);
                int index2 = (rand.Next() % lengthSB);
                Char temp = jumbleSB[index1];
                jumbleSB[index1] = jumbleSB[index2];
                jumbleSB[index2] = temp;

            }

            Console.WriteLine(jumbleSB);

            TextBox1.Text = ListBox1.Text.ToString();
            //TextBox1.Text = ListBox1.Text.Insert(jumbleSB);

这里我需要混淆用户选择的值。当用户选择一个值时,它必须混乱并且必须来到文本框。我无法显示Jumble值。任何帮助请... ??

1 个答案:

答案 0 :(得分:0)

Console.WriteLine(jumbleSB.ToString());