Is there any method / extension method on IEnumerable that allows me to find the index of of an object instance in it? Like IndexOf() in IList?
indexPosition = myEnumerable.IndexOf() ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An
IEnumerableis not an ordered set.Although most IEnumerables are ordered, some (such as
DictionaryorHashSet) are not.Therefore, LINQ does not have an
IndexOfmethod.However, you can write one yourself: