generic NOT constraint where T : !IEnumerable

前端 未结 7 1422
余生分开走
余生分开走 2020-12-03 13:31

As per the title, is it possible to declare type-negating constraints in c# 4 ?

相关标签:
7条回答
  • 2020-12-03 14:04

    You use a constraint so you can ensure the type you use has some properties/methods/... you want to use.

    A generic with a type-negating constraint doesn't make any sense, as there is no purpose to know the absence of some properties/methods you do not want to use.

    0 讨论(0)
提交回复
热议问题