I would like to refine an array.
-
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
-
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
are you sure your code is correct? what is the intention of
base.Add(this)
? eperales -
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
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