0
public class UnityTool<IClass,cbClass>  where IClass, cbClass:class
{
    public static void UnityTest()
    {
        IUnityContainer container = new UnityContainer();

        container.RegisterType<IClass, cbClass>();        
    }
}

I'd like to create a common static method to implement the DI(Dependency Injection). but vs2013 told me that my grammer is wrong. how to solve it?

Satpal
  • 132,252
  • 13
  • 159
  • 168
Youku KMSFan
  • 67
  • 2
  • 12
  • possible duplicate of [Generic method with multiple constraints](http://stackoverflow.com/questions/588643/generic-method-with-multiple-constraints) – Dmitry Pavliv Feb 14 '15 at 08:48

1 Answers1

1

This is correct syntax (separate the where restriction):

public class UnityTool<IClass,cbClass>
          where IClass:class
          where cbClass:class
{
    public static void UnityTest()
    {
        IUnityContainer container = new UnityContainer();

        container.RegisterType<IClass, cbClass>();        
    }
}
Omri Aharon
  • 16,959
  • 5
  • 40
  • 58