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. Newbie: Should I use an array? And how?

Newbie: Should I use an array? And how?

Scheduled Pinned Locked Moved C#
data-structureshelpquestionannouncement
6 Posts 5 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.
  • P Offline
    P Offline
    Phillip Hodges
    wrote on last edited by
    #1

    I am trying to build a small application that collects data about several client applications; it also listens for triggered events and represents them graphically. I have a basic version running ok. I am storing the client info directly into a listview. However I would now like to do other 'clever' things with the collected client info. I was planning to store the data in an array. The problem I have run into is that I do not know the size the array will need to be until I have started to populate it with data. Is there a way to dynamically add data to an array? Or is there another way of storing the client info (so it can be processed and have things done to it)? Thanks in advance... Phil

    "Rules are for the obedience of fools and the guidance of wise men"

    S K E L 4 Replies Last reply
    0
    • P Phillip Hodges

      I am trying to build a small application that collects data about several client applications; it also listens for triggered events and represents them graphically. I have a basic version running ok. I am storing the client info directly into a listview. However I would now like to do other 'clever' things with the collected client info. I was planning to store the data in an array. The problem I have run into is that I do not know the size the array will need to be until I have started to populate it with data. Is there a way to dynamically add data to an array? Or is there another way of storing the client info (so it can be processed and have things done to it)? Thanks in advance... Phil

      "Rules are for the obedience of fools and the guidance of wise men"

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Take a look at the System.Collections and System.Collections.Generic namespaces.


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      P 1 Reply Last reply
      0
      • S Stefan Troschuetz

        Take a look at the System.Collections and System.Collections.Generic namespaces.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        P Offline
        P Offline
        Phillip Hodges
        wrote on last edited by
        #3

        Will do... Thanks

        "Rules are for the obedience of fools and the guidance of wise men"

        1 Reply Last reply
        0
        • P Phillip Hodges

          I am trying to build a small application that collects data about several client applications; it also listens for triggered events and represents them graphically. I have a basic version running ok. I am storing the client info directly into a listview. However I would now like to do other 'clever' things with the collected client info. I was planning to store the data in an array. The problem I have run into is that I do not know the size the array will need to be until I have started to populate it with data. Is there a way to dynamically add data to an array? Or is there another way of storing the client info (so it can be processed and have things done to it)? Thanks in advance... Phil

          "Rules are for the obedience of fools and the guidance of wise men"

          K Offline
          K Offline
          Kevin McFarlane
          wrote on last edited by
          #4

          In .NET 1.1 try ArrayList. In .NET 2.0 try List.

          Kevin

          1 Reply Last reply
          0
          • P Phillip Hodges

            I am trying to build a small application that collects data about several client applications; it also listens for triggered events and represents them graphically. I have a basic version running ok. I am storing the client info directly into a listview. However I would now like to do other 'clever' things with the collected client info. I was planning to store the data in an array. The problem I have run into is that I do not know the size the array will need to be until I have started to populate it with data. Is there a way to dynamically add data to an array? Or is there another way of storing the client info (so it can be processed and have things done to it)? Thanks in advance... Phil

            "Rules are for the obedience of fools and the guidance of wise men"

            E Offline
            E Offline
            ejuanpp
            wrote on last edited by
            #5

            Why don't you use a System.Collections.ArrayList or a System.Collections.Generic.List ?

            1 Reply Last reply
            0
            • P Phillip Hodges

              I am trying to build a small application that collects data about several client applications; it also listens for triggered events and represents them graphically. I have a basic version running ok. I am storing the client info directly into a listview. However I would now like to do other 'clever' things with the collected client info. I was planning to store the data in an array. The problem I have run into is that I do not know the size the array will need to be until I have started to populate it with data. Is there a way to dynamically add data to an array? Or is there another way of storing the client info (so it can be processed and have things done to it)? Thanks in advance... Phil

              "Rules are for the obedience of fools and the guidance of wise men"

              L Offline
              L Offline
              LongRange Shooter
              wrote on last edited by
              #6

              Ahh now this sound like my kind of tool. I planned on writing something similar once to graphically map transactions as they moved through BizTalk. When you use an ArrayList or List<> the structure is such that an initial size is created and dynamically grows as you add additional items. It is better in the performance department if you generally know how many items will go into the array, but it is not a necessity. You can also deploy custom dictionaries as well so you may want to do something like this: Applications go into a List (all the applications inherit the same interface making it easy to store different programs but treat them as the same type) Application fires a trigger event Listener (your code) plots that event but also adds to a Dictionary ReceivedEventEventHandler(object sender, ListenerEventArgs e)
              {
              ICommunicator details = (ICommunicator)sender;
              PlotEvent(details.Name, e.EventObject);
              dictionary[details.Name].Add(e);
              }

              Now you can expose a menu selection to show historical event data for any program in the list, trending across applications, frequency of events across time, and other fun statistical stuff.

              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