Wrox Programmer Forums
|
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2015, 10:51 AM
Friend of Wrox
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default hashtable or collection

Hi,

I'm not sure which is the best to use (if any). I need to temporarily store a small amount of objects (let's say a list of emergency contacts) before saving it to the database.

Should I use hastable or collection for this?

Thanks.
Tulsi
 
Old April 20th, 2015, 02:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I would use a collection like a List<T> over a Hashtable as it's strongly typed and thus type safe.

var list = new List<EmergencyContact>();
list.Add(new EmergencyContact()); // works
list.Add(17); // Doesn't work because 17 is not a EmergencyContact

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Tulsi (April 28th, 2015)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hashtable Scott Rider General .NET 7 July 3rd, 2005 02:25 AM
Hashtable mahulda General .NET 2 August 2nd, 2004 07:49 AM
Hashtable in C# sachin-csharp .NET Framework 2.0 0 July 28th, 2004 01:45 AM
about hashtable csc820203 C# 1 July 11th, 2004 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.