How does OfType() Work?
I read this link about what\'s going on but how exactly does the LINQ provider know how to get all objects matching the specified type. I kno
Your current implementation -- by design -- doesn't support value-types.
If you wanted something closer to LINQ's OfType method, that supports all types, then try this:
public IEnumerable OfType(IEnumerable source)
{
foreach (object item in source)
{
if (item is TResult)
yield return (TResult)item;
}
}