On 2004-02-02, Bob <(E-Mail Removed)> wrote:
> It's not especially important, but I always like to know the best way of doing
> things for when I encounter a case where performance becomes a factor... say I
> have a string array and I want to get a distinct list, that is, get a list
> without duplicates. In SQL this is easy because it's done for you. In code, what
> would be the best practice? Array.Sort(stringarray) followed by n comparisons
> collecting on the changes? Or perhaps adding each string as a key to a
> collection or hashtable and just letting duplicates refusal do the work? I have
> always wondered, are there circumstances when catching errors in quantity like
> this degrade performance? Is it common, avoided?
>
> Bob
Catching exceptions is always expensive and should be avoided where
possible. Personally, I would use the hashtable approach, but I would
probably check if it existed first using the hashtable contains
method... The check would probably be less expensive then catching an
exception in terms of performance.
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
Well, you know, no matter where you go, there you are.
-- Buckaroo Banzai
|