C#: Extension method of base class which returns instances of derived class
<p>I have a class heirarсhy:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyProject.Models;
using MyProject.Extensions;

namespace MyProject.Models
{
    public abstract class Vehicle
    {
        public string Color { get; set; }
    }

    public class Car : Vehicle
    {
        public int Mileage { get; set; }
    }

    public class Boat : Vehicle
    {   
        public int Displacement { get; set; }
    }

}


namespace MyProject.Extensions
{
    public static class VehicleExtensions
    {
        public static IEnumerable&lt;Vehicle&gt; FilterByColor(this IEnumerable&lt;Vehicle&gt; source, string color)
        {
            return source.Where(q =&gt; q.Color == color);
        }
    }
}

namespace MyProject.Controllers
{
    public class IndexController : Controller
    {
        public ActionResult Index()
        {
            List&lt;Car&gt; cars = new List&lt;Car&gt;();
            cars.Add(new Car() { Color = "white", Mileage = 10000 });
            cars.Add(new Car() { Color = "black", Mileage = 20000 });

            IEnumerable&lt;Car&gt; filtered = cars.FilterByColor("black");        
                // Compile error, can not cast IEnumerable&lt;Vehicle&gt; to IEnumerable&lt;Car&gt;

                //.OfType&lt;Car&gt;() - only this helps. I`m looking for another ways

            return View(filtered);
        }
    }
}
</code></pre>

<p>I want to use extension method on <code>IEnumerable&lt;Car&gt;</code> and get <code>IEnumerable&lt;Car&gt;</code> from it but method returns <code>IEnumerable&lt;Vehicle&gt;</code>, because it works across all derived classes - compile error. Only one way I know to fix this is to add call <code>.OfType&lt;Car&gt;()</code>, but is this a preferred way? May be there are better ways?</p>
