petshop4.0中的一段代码 public interface ICategory { /// <summary>
/// Method to get all categories
/// </summary>
/// <returns>Interface to Model Collection Generic of categories</returns>
IList<CategoryInfo> GetCategories();
/// <summary>
/// Get information on a specific category
/// </summary>
/// <param name="categoryId">Unique identifier for a category</param>
/// <returns>Business Entity representing an category</returns>
CategoryInfo GetCategory(string categoryId);
}
我知道IList<CategoryInfo>是范型
表示list中的item是CategoryInfo对象
请问为什么用IList<CategoryInfo>
用List<CategoryInfo>可以吗?两者有什么区别?谢谢
/// Method to get all categories
/// </summary>
/// <returns>Interface to Model Collection Generic of categories</returns>
IList<CategoryInfo> GetCategories();
/// <summary>
/// Get information on a specific category
/// </summary>
/// <param name="categoryId">Unique identifier for a category</param>
/// <returns>Business Entity representing an category</returns>
CategoryInfo GetCategory(string categoryId);
}
我知道IList<CategoryInfo>是范型
表示list中的item是CategoryInfo对象
请问为什么用IList<CategoryInfo>
用List<CategoryInfo>可以吗?两者有什么区别?谢谢
用List<CategoryInfo>可以吗?两者有什么区别?谢谢