📜  csharp 属性作为泛型约束 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:57.759000             🧑  作者: Mango

代码示例1
public static void Insert(this IList list, IList items)
{
    var attributes = typeof(T).GetCustomAttributes(typeof(InsertableAttribute), true);

    if (attributes.Length == 0)
        throw new ArgumentException("T does not have attribute InsertableAttribute");

    /// Logic.
}