共用方式為


編譯器錯誤 CS0455

更新:2007 年 11 月

錯誤訊息

型別參數 'Type Parameter Name' 繼承了衝突的條件約束 'Constraint Name 1' 和 'Constraint Name 2'

發生這個錯誤的兩個常見原因:設定條件約束導致型別參數衍生自兩個不相關的類別,或導致其衍生自類別型別或參考型別條件約束及 struct 型別或實值型別條件約束。若要解決這個錯誤,請自您的繼承階層架構 (Inheritance Hierarchy) 移除衝突。

範例

下列程式碼會產生錯誤 CS0455:

// CS0455.cs
using System;

public class GenericsErrors {
    public class B { }
    public class B2 { }
    public class G6<T> where T : B { public class N<U> where U : B2, T { } } // CS0455
}