2
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);
ここでは、ユーザーが選択した値をジャンパリングする必要があります。ユーザーが値を選択するとき、それは混乱し、テキストボックスに来なければなりません。私はジャンブル値を表示することができません。何か助けてください...?選択したテキストをスクランブルする必要があります
「StringBuilder」から文字列を取得しようとしていますか? 'TextBox1.Text = jumbleSB.ToString(); 'のように –
ありがとうIvan。それは正常に動作しています。 – kiran