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. I would like to refine an array.

I would like to refine an array.

Scheduled Pinned Locked Moved C#
questiondata-structures
3 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.
  • M Offline
    M Offline
    mcgahanfl
    wrote on last edited by
    #1

    1. In the code below I refine an array and add two properties to it. I can add elements to this array but can not read them back. public class C_myList : System.Collections.ArrayList { public C_myList() { } public void Add(string sString, int iNumber) { m_sString = sString; m_iNumber = iNumber; base.Add(this); } //refine the arraylist by adding two properties public int m_iNumber; public string m_sString; } 2. Now I would like to add some items to this array and read them back. I can add them but what is the syntax for reading them back? private void button1_Click(object sender, System.EventArgs e) { C_myList aList = new C_myList(); for(int i=0; i < 20; i++) { aList.Add(i.ToString(), i * 2 ); } /*for(int x =0; x < 5; x++) { int ivalue = xList[x]; int ivalue2= xList[x].m_iMajorTabOrder; }*/ } thanks

    E N 2 Replies Last reply
    0
    • M mcgahanfl

      1. In the code below I refine an array and add two properties to it. I can add elements to this array but can not read them back. public class C_myList : System.Collections.ArrayList { public C_myList() { } public void Add(string sString, int iNumber) { m_sString = sString; m_iNumber = iNumber; base.Add(this); } //refine the arraylist by adding two properties public int m_iNumber; public string m_sString; } 2. Now I would like to add some items to this array and read them back. I can add them but what is the syntax for reading them back? private void button1_Click(object sender, System.EventArgs e) { C_myList aList = new C_myList(); for(int i=0; i < 20; i++) { aList.Add(i.ToString(), i * 2 ); } /*for(int x =0; x < 5; x++) { int ivalue = xList[x]; int ivalue2= xList[x].m_iMajorTabOrder; }*/ } thanks

      E Offline
      E Offline
      Ernesto Perales Soto
      wrote on last edited by
      #2

      are you sure your code is correct? what is the intention of base.Add(this)? eperales

      1 Reply Last reply
      0
      • M mcgahanfl

        1. In the code below I refine an array and add two properties to it. I can add elements to this array but can not read them back. public class C_myList : System.Collections.ArrayList { public C_myList() { } public void Add(string sString, int iNumber) { m_sString = sString; m_iNumber = iNumber; base.Add(this); } //refine the arraylist by adding two properties public int m_iNumber; public string m_sString; } 2. Now I would like to add some items to this array and read them back. I can add them but what is the syntax for reading them back? private void button1_Click(object sender, System.EventArgs e) { C_myList aList = new C_myList(); for(int i=0; i < 20; i++) { aList.Add(i.ToString(), i * 2 ); } /*for(int x =0; x < 5; x++) { int ivalue = xList[x]; int ivalue2= xList[x].m_iMajorTabOrder; }*/ } thanks

        N Offline
        N Offline
        Nnamdi Onyeyiri
        wrote on last edited by
        #3

        make life easy for yourself. store the information in a struct, then use ArrayList to store an array of structs.


        To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
        Another Post by NnamdiOnyeyiri

        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