Hello
So i need to find all string with the same in a List. i don’t need the name of the string but i need the index of it. and now if want to find the index it keep giving me the same index.
you need further information ask below.
Hello
So i need to find all string with the same in a List. i don’t need the name of the string but i need the index of it. and now if want to find the index it keep giving me the same index.
you need further information ask below.
LINQ to the rescue!
var list = new List<string>
{
"Red",
"Blue",
"Green",
"Red",
"Red",
"Green"
};
var indexes = Enumerable.Range(0, list.Count).Where(i => list == "Red").ToList(); // {0, 3, 4}
Aditionally, if you need just one value, use
myAbils.IndexOf("string to find"); //returns -1 if not found