Question: How is it possible to find a specific object from a list?
Lets say i have a function that takes an object and a list that contains objects of this type and returns the number at which position the specific object is found. 

The only way i could think of a solution is to run the list through with a foreach loop, but isn't there a better way?

Thanks

Answer: 
You can use the `IndexOf(T item)` method:

```
myList.IndexOf(myItem);

```

It returns the index of the first occurrence of the item.
> 
> The only way i could think of a solution is to run the list through with a `foreach` loop
> 
> 
> 

Generally, you need a loop (a `for` or `foreach`) to find an object in a list. You could use it directly, or through a function that iterates over list elements, but there is going to be a loop. There is no way around it: unless you know something special about the way the elements of the array are arranged, you have to look at them all.

One case of knowing something special about arrangement of elements is knowing that an array is sorted. If this is the case, and when you know the value of the attribute on which the element is sorted, you can find the element much faster by using binary search.