level 7
例如一个数组1.2.1.3.1
我如何输出这个元素和它的个数
预期结果是1:3。 2:1。 3:1
2014年05月25日 07点05分
1
level 1
string[] source = new string[5] { "1", "2", "1", "3", "1"};
Hashtable h = new Hashtable();
foreach (string a in source)
{
if (h.Contains(a))
h[a] = Convert.ToInt32(h[a]) + 1;
else
h[a] = 1;
}
string ret = "";
foreach (DictionaryEntry d in h)
{
ret += "。" + d.Key + ":" + d.Value;
}
if (ret != "")
ret = ret.Substring(1);
2014年05月25日 15点05分
3