Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C#: What is the best way for managing and searching through small collections of data?

Hello,

okay, here's my problem: I've written a small class containing some atom names as well as their formula symbols and the corresponding image (it's for a game). Storing the data is just fine. But I'm having a problem searching the instantiated classes for a specific, let's say, formula symbol.

This is what I've tried (just for your information):

public class Atom

{

public string name;

public string formSymbol;

public Surface aSurface;

public Atom(string Name, string formula_symbol, Surface surface)

{

this.name=Name;

this.formula_symbol=formSymbol;

this.aSurface=surface;

}

}

But of course searching through instances of a class by formula symbol (string formula_symbol) does not work.

So, what is the fastest and easiest way to search small collections of data? Which data structure should be used?

2 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Have a look at creating custom collection I think this is what you are attempting to do:

    http://www.c-sharpcorner.com/UploadFile/rafidkhali...

  • Anonymous
    1 decade ago

    Actually, any collection will support the find function, as long as you indicate what the key is. You shouldn't have to do the search yourself but give the key (e.g., the name if that is the key) as the option to the find function.

    P.S. the O'Reilly books on C# are really good for this type of information. It's worth buying the programming 3.0 one.

Still have questions? Get your answers by asking now.