I have following code
var list = new List<KeyValuePair<string, int>>();
list.Add(new KeyValuePair<string, int>("Cat", 1));
list.Add(new KeyValuePair<string, int>("Cat", 2));
list.Add(new KeyValuePair<string, int>("Rabbit", 4));
Now I am trying to pass "Cat" and I should get sum of these keys in a variable.If I pass Rabbit, pass only that number
How to get this ? thinking of for-each....
KeyValauePair, for example aPetclass. Then store these pets in aList<Pet>. I guess the value is the age, so you could provide a propertyDateTime Birthdate. TheAgeproperty would be calculated:int Age => DateTime.Today.Year - Birthdate.Year;.