How do I search for values in a dictionary
- by fishhead
what would be the best way to search for a value in a dictionary.
for instance I would like to search for modified objects, would going through the entire collection be the only way to do this?
c#, .net 2.0
class RecA
{
public bool modified {get;set:}
public string{get;set;}
}
class RecA_Dic : Dictionary<int,Rec_A>
{
public bool GetItemByKey(int key,out obj)
{
return this.TryGetValue(key, out obj);
}
public List<Rec_A> getModifiedItems()
{
List<Rec_A> li = new List<Rec_A>();
for(int i=0;i<this.count;i++)
if (((Rec_A)this[i]).modified == true)
li.Add((Rec_A)this[i]);
return li;
}
}