Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

name/value .NET Collection or a .NET name/value Dictionary?

Tags:

c#

can any body guide me weather i use a name/value .NET Collection or a .NET name/value Dictionary for best performance? What is the best approach please? My application is ASP.NET, WCF/WF Web Application. There should be a range of 10 to 30 entries per collection. I also will need users to potentially change a couple entries at tim


2 Answers

With that number it won't matter. It's just plain micro-optimisation.

like image 99
Preet Sangha Avatar answered Dec 19 '25 13:12

Preet Sangha


Performance of what? Insertion? Removal? Adding (at end)? Query? The performance of each depends on the operation. However, for 10-30 you'll be lucky to see any difference, so go with whichever describes your situation most clearly and is most convenience.

If you need the best performance: profile. At those numbers you might find that simply looping over an array/list checking for a match is the quickest approach. But this is the least friendly approach - so only even consider that if this is used in the middle of a tight loop that doesn't already have more significant overheads.

like image 42
Marc Gravell Avatar answered Dec 19 '25 15:12

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!