Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

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 Antworten

Relevanz
  • Anonym
    vor 1 Jahrzehnt
    Beste Antwort

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

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

  • Anonym
    vor 1 Jahrzehnt

    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.

Haben Sie noch Fragen? Jetzt beantworten lassen.