<分区>
举个例子,比如..
public interface IInterface { }
public static void Insert<T>(this IList<T> list, IList<T> items) where T : IInterface
{
// ... logic
}
这很好用,但我想知道是否可以使用属性作为约束。比如……
class InsertableAttribute : Attribute
public static void Insert<T>(this IList<T> list, IList<T> items) where T : [Insertable]
{
// ... logic
}
显然这种语法不起作用,否则我不会发布问题。但我只是好奇这是否可能,以及如何去做。