Use Enumerable.OfType<T>to filter collections by the specified type:
collection.OfType<MyType>().First();
Note. If it is possible that there are no items in the collection MyType, use FirstOrDefault()to avoid an exception.
OfType is , . - ( OfType OfTypeIterator, ):
public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source)
{
foreach (object obj in source)
{
if (!(obj is TResult))
continue;
yield return (TResult)obj;
}
}