in

CodeSmith Community

Your Code. Your Way. Faster!

WANTED: Strongly-TypedCollection template that will handle collection indexing by string AND integer

Last post 02-02-2005 2:16 PM by cnahr. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-27-2005 9:38 PM

    • klange
    • Not Ranked
    • Joined on 01-27-2005
    • Posts 2
    • Points 65

    WANTED: Strongly-TypedCollection template that will handle collection indexing by string AND integer

    Maybe I am not using these templates correctly, however I am looking for a template/collection that allows me to add an object by string only, yet enumerate through the collection with foreach, or for (x=....).
     
    I have not found a simple template for this... does one exist?
     
    Thanks
     
    • Post Points: 60
  • 01-29-2005 10:06 AM In reply to

    • cnahr
    • Top 50 Contributor
    • Joined on 06-03-2003
    • Posts 105
    • Points 2,275

    RE: WANTED: Strongly-TypedCollection template that will handle collection indexing by string AND integer

    I don't quite understand your request. The ArrayList template supports indexing by position (integer) or by an arbitrary property which might be a string. But I don't know what you mean by "adding an object by string only". Could you elaborate, or provide an example?
    • Post Points: 5
  • 02-01-2005 12:56 PM In reply to

    • klange
    • Not Ranked
    • Joined on 01-27-2005
    • Posts 2
    • Points 65

    RE: WANTED: Strongly-TypedCollection template that will handle collection indexing by string AND integer

    I guess I was looking for an already made template that creates a collection that acts like the ado.net dataset tables and columns collections. These two collections allow you to access the collection by string or integer. The last part is just a business rule... I would only like items to be added to the collection by string ( collection.Add(string string).
    • Post Points: 5
  • 02-02-2005 2:16 PM In reply to

    • cnahr
    • Top 50 Contributor
    • Joined on 06-03-2003
    • Posts 105
    • Points 2,275

    RE: WANTED: Strongly-TypedCollection template that will handle collection indexing by string AND integer

    I don't know about ADO.NET or database tables but have you looked at the DictionaryList and SortedList templates? Both collections are dictionaries, i.e. they store a key with each element, and they also allow access by index position. SortedList sorts its elements by their keys while DictionaryList retains the insertion order.
    • Post Points: 5
Page 1 of 1 (4 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems