开发者

Why use IDictionary for Child Classes for NHibernate?

As I read here http://www.theserverside.net/tt/articles/showarticle.tss?id=NHibernate

for example

public class Department
{
    private int id;
    private string name;
    private IDictionary开发者_开发技巧 classes;
    private IDictionary professors;
}

Why not use Generic List ?


Dictionaries are more efficient when performing that kind of lookup. Lists are great but if you're dealing with pairs of values (such as class ID/name, professor ID/person ID) dictionary lookups will be faster. Dictionaries also offer additional functionality, e.g. finding out if an element exists. With a list you'd have to loop through the entire thing (slower and more code) while dictionaries are indexed for you.

Hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜