views:

27

answers:

1

I have a dictionary that looks something like this

test1 : 123
test2 : 456
another1 : abc
test3 : 789
another2 : def

How can I get a count of all the items that begin with "test" in c# framework 3.5?

+4  A: 

You can use LINQ extensions on a dictionary so you are able to do:

int count = dict.Count(D=>D.Key.StartsWith("Test"));
Leom Burke
perfect, thanks!
Chris Conway