otrzymuję następujący błąd:C# generics error: Ograniczenia dla parametru typu "T" metody ...?
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.
Klasa:
public class MyClass : IMyClass
{
public int GetCount<T>(string filter)
where T : class
{
NorthwindEntities db = new NorthwindEntities();
return db.CreateObjectSet<T>().Where(filter).Count();
}
}
Interfejs:
public interface IMyClass
{
int GetCount<T>(string filter);
}
hej Dutchie goed człowiek – user603007
Er lopen hier najlepiej Nederlanders wat rond inderdaad! :) –
hier w OZ wat minder :) thanks anyway – user603007