悬赏分:10 浏览:778 次
//public IList<CategoryInfo> GetCategories() //原文
public Collection<CategoryInfo> GetCategories()//更改后
{
//IList<CategoryInfo> categories = new //原文
List<CategoryInfo>();
Collection<CategoryInfo> categories = new Collection<CategoryInfo>(); //更改后
using(SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_CATEGORIES, null))
{
while (rdr.Read())
{
CategoryInfo cat = new CategoryInfo(rdr.GetString(0), rdr.GetString(1), rdr.GetString(2));
categories.Add(cat);
}
}
return categories;
}
我更改后可以正常运行,我想问下IList与Collection的区别,集合与数组的关系
【petshop】IList与Collection的区别,集合与数组的关系
我看书后的理解:集合更好控制,安全,数组安全性差
还有些知识有些模糊,望大家帮我指正,谢谢
|
4个月前 Vincent Love : 那请问数组与集合有什么区别 |
|
4个月前 Klesh Wong : 具体类的名称还是说明不了什么问题的,到底它是列表还是集合,还得看它实现了哪些接口 |
|
4个月前 Vincent Love : 麒麟.NET Klesh Wong ---- 谢谢两位的回答 慢慢理解了集合与数组的区别,也了解了arraylist与ilist的相关知识 |