G+_abby Sand Posted September 27, 2014 Share Posted September 27, 2014 Okay I was watching the latest episode on collections but for the life of me I cannot understand why you would you use a dictionary instead of a list. I mean a list is easier Link to comment Share on other sites More sharing options...
G+_Nate Follmer Posted September 28, 2014 Share Posted September 28, 2014 Use a dictionary when you want to store data together that's meaningful (for example, a bank account with a PIN number). Lists only pair values and positions, where a dictionary can pair values with other data. The quickest way I've heard it defined: Lists deal with order, Dictionaries deal with association. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted September 28, 2014 Share Posted September 28, 2014 Different collections use different methods to access data, and so have different properties like memory use and efficiency. If, for example, you have 1000 records that you want to look up by name, if you just have them in a list you'll have to search through all of them comparing names to find one every time you do a lookup. That's an average of 500 comparisons per lookup, dreadfully slow. If you keep them sorted, you can use a binary search and average 10 comparisons. But a dictionary uses a hash function to access members with fewer than 2 comparisons on average, so looking up by name is very efficient (but there's a slight catch: the dictionary takes more memory than a list. Such tradeoffs are common in choosing data structures and algorithms). Link to comment Share on other sites More sharing options...
G+_Jani Turunen Posted September 29, 2014 Share Posted September 29, 2014 like for example you can use collections like this as you have database you set public DBset Movies {get, set;} that use Entity Framework what you can add like any nuget package Link to comment Share on other sites More sharing options...
Recommended Posts