Creating a List of objects of a particular type only I'm using an interface IloadPattern on deriving 3 classes from it LinearLoadingPattern , JointsLoadingPattern , AreaLoadingPattern. At some point, I'm creating a list all the objects created from those classes. 

At a later point, I want to retrieve list of a particular object (JointsLoadingPattern) from the above list, I'm wondering if there is a better way to do this.  

Below is the way I'm doing it.

public List&lt;JointsLoadingPattern&gt; GetJointLoads()
{
    List&lt;JointsLoadingPattern&gt; jointLoads =  new List&lt;JointsLoadingPattern&gt;();

    foreach(ILoadPattern loadCase in AllLoadCases)
    {
        if(loadCase.GetType() ==typeof(JointsLoadingPattern))
        {
            jointLoads.Add((JointsLoadingPattern)loadCase);
        }
    }

    return jointLoads;
}
You can use the LINQ extension method IEnumerable.OfType&lt;TResult&gt;(), it returns any elements matching the type of the specified generic type argument:

var jointLoads = AllLoadCases.OfType&lt;JointsLoadingPattern&gt;();


This will return an IEnumerable&lt;JointsLoadingPattern&gt;, you can always call .ToList() to convert it.

Update

As noted in the comments, since OfType&lt;TResult&gt; uses the is operator internally, it will also return any sub-types of TResult type. If you want to avoid this you can write your own extension method:

public static class Extensions
{
    public static IEnumerable&lt;TResult&gt; OfExactType&lt;T, TResult&gt;(this IEnumerable&lt;T&gt; source)
        where TResult : T
    {
        return OfExactType&lt;TResult&gt;(source);
    }

    public static IEnumerable&lt;TResult&gt; OfExactType&lt;TResult&gt;(this IEnumerable source)
    {
        if (source == null) throw new ArgumentNullException(nameof(source));
        return OfExactTypeImpl&lt;TResult&gt;(source);
    }

    private static IEnumerable&lt;TResult&gt; OfExactTypeImpl&lt;TResult&gt;(IEnumerable source)
    {
        var type = typeof(TResult);
        foreach (var t in source)
        {
            if (t.GetType() == type)
            {
                yield return (TResult)t;
            }
        }
    }
}


Example usage:

AllLoadCases.OfExactType&lt;ILoadPattern, JointsLoadingPattern&gt;();
AllLoadCases.OfExactType&lt;JointsLoadingPattern&gt;();


The main difference between the 2 being, that in 1 case you will get a compile-time error when you attempt to provide invalid types, while in the other case this, will be ignored and it will simply return nothing.