문제

So I have a class called Repository which holds this method:

public IEnumerable<TModel> UpdateOrCreate<TModel>(ICollection<TModel> itemsToUpdate)
        where TModel : EndpointModelBase
{
    //Do Stuff
}

How can I call this method with the correct parameter? My trouble comes with trying to make an ICollection for the parameter to pass in?

도움이 되었습니까?

해결책

You can pass List<EndpointModelBase> since it implements ICollection<T>.

List<EndpointModelBase> itemsToUpdate = new List<EndpointModelBase>();
UpdateOrCreate<EndpointModelBase>(itemsToUpdate);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top