//instantiate a dictionary list
Dictionary_PointDic = new
Dictionary();
public Dictionary
PointDic
{
get { return _PointDic; }
set { _PointDic = value; }
}
//add value to named key
public void AddPoints(int point, string
ruleName)
{
int temp = 0;
if (!_PointDic.TryGetValue(ruleName, out
temp))
{
_PointDic.Add(ruleName,
point);
}
else
{
_PointDic.Remove(ruleName);
_PointDic.Add(ruleName,
point);
}
}
//sum up the values in the dictionary list
public int
CalculatePoints()
{
int totalpoints = 0;
foreach
(KeyValuePairs in _PointDic)
{
totalpoints +=
(int)s.Value;
}
return totalpoints;
}
Wednesday, July 25, 2007
How to enumerate Generic Dictionary .NET list
At first i found that enumerating a .net Dictionary class seem to be difficult but later i found that there is a way of doing this for example:
Subscribe to:
Post Comments (Atom)
3 comments:
You have really great taste on catch article titles, even when you are not interested in this topic you push to read it
I really like when people are expressing their opinion and thought. So I like the way you are writing
I read about it some days ago in another blog and the main things that you mention here are very similar
Post a Comment