x


Search array by variables.

I have an array of Item with different variables, such as Weight, Value, Name, and junk like that. I know how to use Array.Find() and Array.FindAll() using a boolean predicate, but how would I go about specifically finding an Item by its variable?

For example, I want to have a function that can find specific items. public Item GetItem(string itemName) for example, would find the first Item named itemName.

What is the most efficient way to do that?

more ▼

asked May 17 '12 at 08:26 PM

Nemox gravatar image

Nemox
169 11 16 19

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You're probably wanting to use something like a LIST if you want that added functionality. If you're using C#, learning how to use LINQ to form queries is extremely useful and easy to learn as well.

A good tutorial for getting started with LINQ would be the following link, by Prime31:

http://www.youtube.com/watch?v=IX041ZvgQKE

more ▼

answered May 17 '12 at 08:47 PM

dannyskim gravatar image

dannyskim
3.9k 5 7 19

ilu <3

Heheh, this will be very handy indeed. I quite understand the grammar of C# fluently, it's just my vocabulary that needs work.

May 17 '12 at 08:51 PM Nemox
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1363
x823
x208
x2
x1

asked: May 17 '12 at 08:26 PM

Seen: 386 times

Last Updated: May 17 '12 at 08:51 PM