Use OfType<T>()
Use KnownTypeCode.