Public Struct Naturgas
Public int Id;
Public string Fabrikat;
Public string Effekt;
End Structure
class SomeClass {
ArrayList _naturgasList = new ArrayList();
public void Add(Reader reader) { // or whatever the class of your reader
variable is
Naturgas lst = new Naturgas();
lst.Id = int32.Parse(reader[0].ToString());
lst.Fabrikat = reader[1].ToString();
lst.Effekt = reader[2].ToString();
_naturgasList.Add(lst);
}
public Naturgas FindEffektById(int Id) {
for (int i = 0, i < _natrugasList.Count, i++) {
if (_naturgasList[i].Id == Id) {
return _naturgasList[i].Effekt;
}
}
return null;
}
}
Something like that anyway.
Sorry, I don't do VB. It's a religious thing.
Peter
"Morten Snedker" <morten_spammenot_ATdbconsult.dkwrote in message
news:4t********************************@4ax.com...
So far I've been blessed with a whole-lotta nice help and explaining
in here, so I'll give it a go once again:
I have some difficulty searching an array.
I have a structure:
Public Structure Naturgas
Public Id As Integer
Public Fabrikat As String
Public Effekt As String
End Structure
This is assigned to an ArrayList called _naturgasList:
lst.Id = CType(reader(0).ToString, Integer)
lst.Fabrikat = reader(1).ToString
lst.Effekt = reader(2).ToString
_naturgasList.Add(lst)
Now, in _naturgasList I wish to look up Effekt via Id. How do I do
this?
The runtime content of the Array is at www.dbconsult.dk/db/array.jpg
Thanks in advance for any help.
Regards /Snedker