Using Attributes for Generic Constraints [duplicate]
问题 This question already has an answer here: Can you use “where” to require an attribute in c#? 5 answers Given an example such as .. public interface IInterface { } public static void Insert<T>(this IList<T> list, IList<T> items) where T : IInterface { // ... logic } This works fine, but I was wondering if it is possible to use an Attribute as a constraint. Such as ... class InsertableAttribute : Attribute public static void Insert<T>(this IList<T> list, IList<T> items) where T : [Insertable] {