又是这问题。。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string CreateOrderList(string inputStr, bool isRemoveSameItem)
{
//删除字符串中的空格字符
inputStr = inputStr.Replace(" ", "");
inputStr = inputStr.Trim();
Hashtable hs = new Hashtable();
ListcharArray = new List ();
foreach (char c in inputStr)
{
//是否移除相同项目
if (isRemoveSameItem)
{
if (!hs.ContainsKey(c))
{
hs.Add(c, c);
charArray.Add(c);
}
}
else
charArray.Add(c);
}
charArray.Sort();
string s="";
foreach(char cc in charArray)
{
s += cc;
}
return s;
}
private void bt_creatOrder1_Click(object sender, EventArgs e)
{
if (tb_order1.Text != string.Empty)
{
this.tb_result1.Text = CreateOrderList(tb_order1.Text, true);
lb_msg.Text = "元素2,创建顺序表完成!";
}
}
private void bt_creatOrder2_Click(object sender, EventArgs e)
{
if (tb_order2.Text != string.Empty)
{
this.tb_result2.Text = CreateOrderList(tb_order2.Text, true);
lb_msg.Text = "元素2,创建顺序表完成!";
}
}
private void bt_creatOrder12_Click(object sender, EventArgs e)
{
if (tb_order1.Text != string.Empty && this.tb_order2.Text != string.Empty)
{
this.tb_result.Text = CreateOrderList(tb_order1.Text + tb_order2.Text, true);
lb_msg.Text = "合并顺序表操作完成!";
}
}
}