110,533
社区成员
发帖
与我相关
我的任务
分享
<a>
<p name="xmlfile" value="c://load"/>
<p name="sizeX" value="100">
<p name="sizeY" value="200">
<p name="sizeZ" value="300">
<a>
<a>
<p name="xmlfile" value="c://load"/>
<p name="sizeX" value="100">
<p name="sizeY" value="300">
<p name="sizeZ" value="300">
<a>
<a>
<p name="xmlfile" value="c://load"/>
<p name="sizeX" value="100">
<p name="sizeY" value="400">
<p name="sizeZ" value="300">
<a>
private Dictionary<string, Tuple<string, string, string, int>> dic = new Dictionary<string, Tuple<string, string, string, int>>();
private void button3_Click(object sender, EventArgs e)
{
string str = this.textBox1.Text;
string width = this.textBox2.Text;
string depth = this.textBox3.Text;
string height = this.textBox4.Text;
if (dic.ContainsKey(str))
{
if (dic[str].Item1.Contains(width))
{
if (dic[str].Item2.Contains(depth))
{
if (dic[str].Item3.Contains(height))
{
dic[str] = new Tuple<string, string, string, int>(width, depth, height, dic[str].Item4 + 1);
}
else
{
dic[str] = new Tuple<string, string, string, int>(width, depth, height, 1);
}
}
else
{
dic[str] = new Tuple<string, string, string, int>(width, depth, height, 1);
}
}
else
{
dic[str] = new Tuple<string, string, string, int>(width, depth, height, 1);
}
}
else
{
dic.Add(str, new Tuple<string, string, string, int>(width, depth, height, 1));
}
}
private void button4_Click(object sender, EventArgs e)
{
foreach (var key in dic.Keys)
{
MessageBox.Show(dic[key.ToString()].Item4.ToString());
}
}
测试数据一:
100
100
100
100
单击4次button3 单击button4输出4
改数据
100
100
200
100
单击2次button3 单击button4输出2 少了上面的4 就是被重新赋值了。。我想都在里面 因为数据都是需要的。。又不可以用集合。。因为这样键怎么找到不同的值呢。。 求解