2012-04-19 62 views
4
private Result Execute(
    out T returnValue, 
    string storedProcedureName, 
    Hashtable parameters, 
    ExecuteType executeType) 
    where T : class 

以下错误的含义是什么?如何解决?非通用声明中不允许使用约束条件

错误在哪里:约束不以非通用声明

回答

19
private Result Execute<T>(
          out T returnValue, 
          string storedProcedureName, 
          Hashtable parameters, 
          ExecuteType executeType 
         ) where T : class 

Execute后所需的<T>允许的。

+0

非常好!完工。谢谢各不相同 – 2012-04-20 12:54:07

+0

什么是扩展方法,它会使用扩展方法吗? – 2017-05-05 09:27:57

1

是的它也适用于扩展方法。

class Class1<T> where T:class 
{ 
    public void MethodA() 
    { 
     Console.WriteLine("Method A"); 
    } 
} 

static class ExtenstionTest 
{ 
    public static void MethodA<T>(this Class1<T> A1, int a) where T : class 
    { 
     Console.WriteLine("Extension Method A" + a); 
    } 
} 
+0

好的,扩展方法也与泛型一起使用。 – 2017-05-05 09:35:26