Mid Collections

How do you get the index of an element in a List<T>?

Use IndexOf(item) or FindIndex(predicate).

Example:

int index = list.IndexOf(10);

int indexByCondition = list.FindIndex(x => x > 100);

Follow:

📘 C# Dictionary<TKey, TValue> –

Interview Questions & Answers

More from C# Programming Tutorial

All questions for this course