C# Generics won't allow Delegate Type Constraints

前端 未结 8 1277
别跟我提以往
别跟我提以往 2020-11-28 08:01

Is it possible to define a class in C# such that

class GenericCollection : SomeBaseCollection where T : Delegate

I couldn

8条回答
  •  日久生厌
    2020-11-28 08:34

    According to MSDN

    Compiler Error CS0702

    Constraint cannot be special class 'identifier' The following types may not be used as constraints:

    • System.Object
    • System.Array
    • System.Delegate
    • System.Enum
    • System.ValueType.

提交回复
热议问题