C# Conversion Error Help
I am getting this error.
Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<ModelBase.IModel>' to 'System.Collections.Generic.List<ModelBase.User>'
User inherits IModel, but I am not casting correctly.
I am trying to do something like this:
List<User> users = (List<User>)this.GetAll();
// GetAll() return type is List<IModel>
开发者_如何学Go
Try this:
List<User> users = this.GetAll().Cast<User>().ToList();
精彩评论