where T : class泛型類型約束


類型參數約束,.NET支持的類型參數約束有以下五種:

where T : struct | T必須是一個結構類型
where T : class T必須是一個類(class)類型
where T : new() | T必須要有一個無參構造函數
where T : NameOfBaseClass | T必須繼承名為NameOfBaseClass的類
where T : NameOfInterface | T必須實現名為NameOfInterface的接口

微軟MSDN詳細說明:http://msdn.microsoft.com/zh-cn/library/bb384067.aspx


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM