I have MYDemoClass.cs
[Serializable]
public class MYDemoClass<T> where T : class
{
Now in interface IMyTask
I create method like following
public interface IMyTask
{
MYDemoClass<object> Update(int Id, MYDemoClass<T> data) where T : class;
}
in MyTaskClass.cs
public MYDemoClass<object> Update(int Id, MYDemoClass<T> data) where T : class
{
which gives me build error
Constraints are not allowed on non-generic declarations
why so? If I have already declareMYDemoClass<T> where T : class
?
T
doesn't exist as a type parameter, as you haven't introduced it as a type parameter...class MYDemoClass<T> where T : class
is a generic class. it has nothing to do with generic methods. you have to create a generic method too. you cant haveMYDemoClass<T>
inside non generic. in non generic method you can doMYDemoClass<int>
or use some known types.