【问题标题】:Is there any way to restrict a generic type parameter to an anonymous type?有没有办法将泛型类型参数限制为匿名类型?
【发布时间】:2011-05-11 13:43:30
【问题描述】:

在 C# 4.0 中有没有办法将泛型类型参数限制为匿名类型?或者where T: class是我最接近的吗?

【问题讨论】:

    标签: c# .net generics c#-4.0 anonymous-types


    【解决方案1】:

    不,C# 中没有这样的约束。您可以添加执行时检查以验证该类型是否具有 the characteristics of an anonymous type

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-26
      • 1970-01-01
      • 2018-07-21
      • 2017-11-17
      • 1970-01-01
      相关资源
      最近更新 更多