Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .NET Collections

.NET Collections

Scheduled Pinned Locked Moved C#
questioncsharpjavadotnetoop
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I've been looking over the Collection classes available through the .NET framework and it seems that LinkedList hasn't been provided (Unless it is in some other namespace which I haven't checked - If so could you point it out - Thanks!). Any ideas as to why they haven't included it in the Framework? It is a very useful data structure and has many uses just as ArrayList does. Actually... it would be a good article to compare the Collections framework that .NET and Java provide. Cause I know that the Java Collections framework is heavily based on inheritance and abstract classes. It would be an interesting article to see the differences between them. As a side question - Are the .NET Enumerators the same as the Java Iterators? Thanks very much. Mohnish

    J 1 Reply Last reply
    0
    • L Lost User

      Hi, I've been looking over the Collection classes available through the .NET framework and it seems that LinkedList hasn't been provided (Unless it is in some other namespace which I haven't checked - If so could you point it out - Thanks!). Any ideas as to why they haven't included it in the Framework? It is a very useful data structure and has many uses just as ArrayList does. Actually... it would be a good article to compare the Collections framework that .NET and Java provide. Cause I know that the Java Collections framework is heavily based on inheritance and abstract classes. It would be an interesting article to see the differences between them. As a side question - Are the .NET Enumerators the same as the Java Iterators? Thanks very much. Mohnish

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      mohn3310 wrote: Any ideas as to why they haven't included it in the Framework? Good question, it does seem odd that it isn't there. You could easily create your own version of it though. If you don't know how to create a linked list there are many places on the web that will give you code for doing it :) mohn3310 wrote: Are the .NET Enumerators the same as the Java Iterators? Enumerators in .NET are used to go through a collection an element at a time.

      IEnumerator ie = myCollection.GetEnumerator();
      while(ie.MoveNext) {
      System.Console.WriteLine("object: " + ie.Current.ToString());
      }

      or if you are using C# you can use foreach

      foreach(object foo in myCollection) {
      System.Console.WriteLine("object: " + foo.ToString();
      }

      Simple, eh? :) HTH, James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

      M 1 Reply Last reply
      0
      • J James T Johnson

        mohn3310 wrote: Any ideas as to why they haven't included it in the Framework? Good question, it does seem odd that it isn't there. You could easily create your own version of it though. If you don't know how to create a linked list there are many places on the web that will give you code for doing it :) mohn3310 wrote: Are the .NET Enumerators the same as the Java Iterators? Enumerators in .NET are used to go through a collection an element at a time.

        IEnumerator ie = myCollection.GetEnumerator();
        while(ie.MoveNext) {
        System.Console.WriteLine("object: " + ie.Current.ToString());
        }

        or if you are using C# you can use foreach

        foreach(object foo in myCollection) {
        System.Console.WriteLine("object: " + foo.ToString();
        }

        Simple, eh? :) HTH, James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

        M Offline
        M Offline
        mohn3310
        wrote on last edited by
        #3

        Thanks James! Yes, LinkedLists are relatively simple to create and there are lots of examples on the web, but I was just wondering why they didn't include it since it's such a generic data structure. Normally we would create wrappers to ArrayLists or LinkedLists to make them typesafe (using our own classes) rather than using Objects. Yeah, enumerators do seem to act like iterators in java. Cool... thnx again Mohnish

        J 1 Reply Last reply
        0
        • M mohn3310

          Thanks James! Yes, LinkedLists are relatively simple to create and there are lots of examples on the web, but I was just wondering why they didn't include it since it's such a generic data structure. Normally we would create wrappers to ArrayLists or LinkedLists to make them typesafe (using our own classes) rather than using Objects. Yeah, enumerators do seem to act like iterators in java. Cool... thnx again Mohnish

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          mohn3310 wrote: Normally we would create wrappers to ArrayLists or LinkedLists to make them typesafe (using our own classes) rather than using Objects. Microsoft has made that part easier on us developers :) Collection Generator for .NET 1.0 creates a collection based on ArrayLists to store objects of a specified type. Until .NET supports generics this is the best solution to it. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups