Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / March 2004

Tip: Looking for answers? Try searching our database.

Use a DataTable in place of a HashTable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
_eee_ - 04 Mar 2004 10:45 GMT
I have been using a HashTable to store name/value pairs, but now I
need to add a third element (name/value/flag).  I still need to be
able to index by ["Name"], and I'd like to keep lookup speed as high
as possible.

I'm considering using a DataTable instead of the HashTable since I
have to store the values to a database eventually anyway.  It seems
like the DataTable can do what the HashTable is doing in this case,
but I'm concerned about efficiency.

Does anyone happen to know the tradeoffs in using the DataTable
instead?  I was originally considering building both tables at the
same time, but that seems unnecessary.
Miha Markic [MVP C#] - 04 Mar 2004 10:56 GMT
Hi,

You might create a custom value class that encapsulates value and flag?
Using a DataTable seems a bit of an overkill to me.

Signature

Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

> I have been using a HashTable to store name/value pairs, but now I
> need to add a third element (name/value/flag).  I still need to be
[quoted text clipped - 9 lines]
> instead?  I was originally considering building both tables at the
> same time, but that seems unnecessary.
_eee_ - 04 Mar 2004 20:36 GMT
>"_eee_" <_notme@nomail.com> wrote in message
>> I have been using a HashTable to store name/value pairs, but now I
[quoted text clipped - 4 lines]
>> I'm considering using a DataTable instead of the HashTable since I
>> have to store the values to a database eventually anyway.

>You might create a custom value class that encapsulates value and flag?
>Using a DataTable seems a bit of an overkill to me.

Hi Miha,

You mean slow runtime?  I could live with the increased code
complexity of the DataTable as long as it doesn't slow runtime down to
a crawl.
Miha Markic [MVP C#] - 05 Mar 2004 08:48 GMT
Yes, I mean that DataTable has overheads.
Rather use the "holder" class approach.

Signature

Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

> >"_eee_" <_notme@nomail.com> wrote in message
> >> I have been using a HashTable to store name/value pairs, but now I
[quoted text clipped - 13 lines]
> complexity of the DataTable as long as it doesn't slow runtime down to
> a crawl.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.