C# - How do I get an item in a collection directly?

  • Thread starter Thread starter John Boy
  • Start date Start date
J

John Boy

Hi,

I have a collection of 'Address' objects and need to get one of these
addresses by 'AddressID' not collection index. VB had dictionaries and
collections which did this fine by setting a 'key' field. Can't you do
this in C#?

Thanks,

John.
 
In c# 2.0, I'd suggest
Dictionary<string, Adress> d = new Dictionary<string, Adress>();

In c# 1.1, I'd probably use a Hashtable.
 
Back
Top