Is there a way to get the index of each object in a List that is null?
For example:
List<string> list = new List<string>() { "1", null, "2", null, "3" };
Is it possible to get the information that list[1] and list[3] is null? In the best case I would get another list that provides me all the indexes that are null.
Yes, the simplest option would probably be:
var nullIndexes = list.Select((value, index) => new { value, index })
.Where(pair => pair.value == null)
.Select(pair => pair.index)
.ToList();
See more on this question at Stackoverflow