okay, I have a list of class objects like so:
List<fruit> lst = new List<fruit>();
lst.Add(orange);
lst.Add(apple);
lst.Add(grape);
lst.Add(grape);
lst.Add(orange);
lst.Add(pear);
lst.Add(apple);
I want to be able to ask the list something like
GetIndex(“orange”, 2) and have it return (in this case) the index # for the second instance of object in question (position 4).
This list will be dynamically filled, and it may not even have an orange to begin with. If it does, I want the instance number of the second parameter. So I can get the second orange, or get fifth mango, etc.
list.IndexOf(orange) returns the first instance of any duplicates, so I need something else.
Any ideas?
PS: I failed to mention that the first param will be a string!
You can extend classes with your own method for that class, sadly this is not possible for generic classes, so instead you give the type with the method.