收到以下錯誤:c#泛型錯誤:方法的類型參數'T'的約束......?
Error 1 The constraints for type parameter '
T
' of method
'genericstuff.Models.MyClass.GetCount<T>(string)
' must match the constraints for type
parameter 'T
' of interface method 'genericstuff.IMyClass.GetCount<T>(string)
'. Consider
using an explicit interface implementation instead.
類:
public class MyClass : IMyClass
{
public int GetCount<T>(string filter)
where T : class
{
NorthwindEntities db = new NorthwindEntities();
return db.CreateObjectSet<T>().Where(filter).Count();
}
}
接口:
public interface IMyClass
{
int GetCount<T>(string filter);
}
hey Dutchie goed man – user603007 2012-08-07 12:39:52
Er lopen hier best wat Nederlanders rond inderdaad! :) – 2012-08-07 12:40:57
在OZ笏意見塔:)但無論如何 – user603007 2012-08-07 12:59:36