Posted on Monday, May 10, 2010 5:01 PM
System.Collections.Generic.
SortedDictionary<string, long> Dic = new SortedDictionary<string, long>();
.
..
...
....
...
..
.
Collect some key's and there values
//contains list already the key value (here represented by: ext)?
if (Dic.Keys.Contains(ext))
{
//found in list then add 1 to the value.
long i = Dic[ext]; // get the value for the key
i++;//add 1
Dic[ext] = i;//update value
}
else
{
//not? then add this key and set default value to 1.
Dic.Add(ext, 1);
}
.
..
...
....
...
..
.
Read out the sortedlist
//print dictionary e.g. to screen
foreach (var pair in Dic)
{
this.textBox1.AppendText(pair.ToString() + "\r\n");
Application.DoEvents();
}
//remove all entries
Dic.Clear();
Output will be like
[the key, the value]
[the key, the value]
[the key, the value]
[the key, the value]
etc, etc..