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

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.
 
R

Robert Jeppesen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top