My Code looks like that:
public class Artikel : List<Datenschicht.tb_Artikel>
{
....
public void DoSomething()
{
..
}
}
Now i want to do sth like that:
Artikel[0].DoSomething();
How can i get this number (0) in the method “DoSomething”?
Thank you for your Help!
It sounds like you want the instance of
tb_Artikelto know what index it occupies in theList<>structure. If so this is not possible. Objects don’t have any knowledge of their containers. Primarily because objects can be contained in multipleList<>at any given time. Which number would it choose then?One option though is to simply have the
DoSomethingtake theintvalue directly. Then let it choose the value from itself to operate on