Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What other improvements in .NET's Dictionary vs. HashTable besides [un]boxing?

Trying to convince someone to switch from .NET 1.1

I saw people saying that one advantage of using the Dictionary class in post .NET 1.1 is performance increases due to not having to unbox/cast objects. Are there another improvements besides that?

Or any other general advantages to moving away from .NET 1.1 ?

like image 613
teriyaki Avatar asked Nov 28 '22 10:11

teriyaki


1 Answers

George, I can answer that question in two words:

Type Safety.

And now I shall expand. Probably the single biggest benefit of moving to .NET 2.0 is generics and generic collections. A bigger benefit IMO than the performance improvements of not having to box and unbox value types (which isn't really that big a deal unless you've got huge ArrayLists of ints that you process through continuously) is not having to cast to and from object. Or, in two words, "type safety". You know at compile time what the underlying type of the collection is, and you cannot deviate from that. With a non-generic collection, you can throw any old thing in there and unless you reflect on the type (which is an even bigger performance hit than boxing) before you cast, you could wind up with an InvalidCastException being thrown at a bad time.

That said, why stop at 2.0? .NET 3.0 has WCF and WPF, which are great new ways to communicate and present. .NET 3.5 has LINQ and lambda expressions, which will change the way you process a collection.

Tell your friend to stop living in the dark ages. It's time to update!

like image 161
Randolpho Avatar answered Jan 18 '23 22:01

Randolpho