If I declare a List like,
List<object[]> People = new List<object[]>();
(in which object[]
has two elements)
People.Add(new object[] {"Sam", 18});
Is there a way I can find the index of a person like this?
People.IndexOf(new object[] {"Sam", 18});
I've tried doing it like it is above, but it returns -1
.
Solved this in my own crappy way by creating an extension method which takes a string parameter and loops through the list until it matches with one, then returns that index.
public static int OIndexOf(this List<object[]> List, string Check)
{
for (int I = 0; I < List.Count; I++)
{
if ((string)List[I][0] == Check)
return I;
}
return -1;
}