Mondeo Posted April 17, 2007 Posted April 17, 2007 I have a custom class which represents an item in my shopping basket (e-commerce site) Is there a collection object which I can add all the shopping cart items to (normally I just use a datatable in the session to hold this info) but I want to try it by just adding the collection to the session. Whats the best collection object to use for this? Thanks Quote
Administrators PlausiblyDamp Posted April 17, 2007 Administrators Posted April 17, 2007 You could just use something simple like an ArrayList or HashTable if you are using .Net 1 / 1.1. If you are using .Net then something like a generic List or Dictionary may be easier to use. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted April 18, 2007 Posted April 18, 2007 I would inherit from CollectionBase and create a strongly typed custom collection. This way you know any object in the collection is of the correct type, etc... Here's a nifty little example http://www.c-sharpcorner.com/UploadFile/rafidkhalidabdullah/CreatingStronglyTypedCustomCollectionsinCS11302005020315AM/CreatingStronglyTypedCustomCollectionsinCS.aspx Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
amir100 Posted April 19, 2007 Posted April 19, 2007 I would inherit from CollectionBase and create a strongly typed custom collection. This way you know any object in the collection is of the correct type, etc... Here's a nifty little example http://www.c-sharpcorner.com/UploadFile/rafidkhalidabdullah/CreatingStronglyTypedCustomCollectionsinCS11302005020315AM/CreatingStronglyTypedCustomCollectionsinCS.aspx Nice idea. Even the thought of using a strongly typed custom collection didn't occur to me. :p Quote Amir Syafrudin
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.