Converting models into a list of ViewModels I have the following code:

public abstract class BaseViewModel&lt;PrimaryKey, ModelType&gt;
{
    //Some base fields

    public static List&lt;T&gt; Convert&lt;T&gt;(IEnumerable&lt;ModelType&gt; collection) 
        where T : BaseViewModel&lt;PrimaryKey, ModelType&gt;, new()
    {
        var list = new List&lt;T&gt;();

        if (collection != null)
        {
            foreach (var item in collection)
            {
                var view = new T();
                view.Value = item;

                list.Add(view);
            }
        }

        return list;
    }
}


Of course, it works because it requires to I set a generic type.

var list = GroupViewModel.Convert&lt;GroupViewModel&gt;(model);


There is GroupViewModel extends from BaseViewModel. But how can I reduce this generic casting to it will get GroupViewModel type automaticaly when I call it so: var list = GroupViewModel.Convert(model);.
Is it possible? Just I learn C# only.
I don't know what to say more then:


make it an extension and return an IEnumerable&lt;T&gt; instead by using linq


do you mean something like this?

public static IEnumerable&lt;T&gt; Convert&lt;T&gt;(this IEnumerable&lt;ModelType&gt; modelTypes) 
    where T : BaseViewModel&lt;PrimaryKey, ModelType&gt;, new()
{
    return modelTypes.Select(x =&gt; new T { Value = x });    
}


use it:

var groupViewModels = modelTypes.Convert&lt;GroupViewModel&gt;().ToList();