You can use the Select()
extension method to project each element into a tuple with its index, then use the FirstOrDefault()
extension method to find the first element in the sequence that matches a specific condition (in this case, the element itself), and finally return the index of that element.
main.cs387 chars17 lines
Output:
main.cs24 chars2 lines
gistlibby LogSnag