2010-12-17 51 views

回答

2

一個簡單的例子,

// a Product can belong to many ProductCollections 
class Product 
{ 
    // some properties 
} 

// a ProductCollection can contain many Products 
class ProductCollection 
{ 
    public IList<Product> Products { get; private set; }  
    // ... 
    // other collection properties 
} 

您可能要組/組織的產品在泛型集合,並允許最終用戶創建新的集合。

某些產品被用於在網站上展示產品,其他產品被用於管理(人A負責...,其他產品負責人B), 某些產品是缺貨產品中的keps ,其他人在'需要更新'收藏等...

在這種情況下,您很可能總是希望使用特定集合檢索產品。

如果你需要一個產品所屬的所有集合,那麼你總是可以爲它寫一個函數。

相關問題