I have a list who have some element like A B C D.
I want to get the index of B.
How i can get it?
I want to do this in C#.
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.
This can be as simple as:
where
bis the thing to find, however there is an ambiguity here over the definition of equality. By default, classes will use reference-equality. A common mistake is creating two class instances that have identical fields, and expecting them to count as equal. To do this, you should really overrideEquals(and ideally implementIEquatable<T>for the sameT). If you overrideEquals, you should also overrideGetHashCode, and ideally the==and!=operators.Another alternative is to find the match with a predicate or comparer, which can avoid all that work