Hi,

I have a list of a few thousand names. I actually have last name, first name, phone number, etc and more info. I'm going to make a class to contain the data. so I'll have like a people object with for example a last name field. I'm going to store these in like an array list. Lets say i have 100 items in array list. Maybe last name smith is on index 3 21 and 63. I'd like a data structure where i can easily search for smith and get indexes 3 21 and 63.

Brute force is simply loop through complete array checking last name and grabbing index each time i find smith. Ideally id like to have more efficiency. In c++ I'd use a multi map but i don't see that that exists in vb.net. A dictionary wont work because its 1:1.

Name of data structure, short description of how to use it and web help reference page would be nice.
thanks
Mike

You could add an "ID" property of type Integer to your peopleClass and then doing a LINQ query like:

Dim var = (From p as peopleClass in myArray where p.LastName="Smith" Select p.ID)

var will then hold all matching ID's.

This LINQ query idea worked out nicely. thanks

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.