when a method is called i want to get first index value from an arraylist and when the same methid is called nxt time i want to get the second index value from the same arraylist...how?
-
when a method is called i want to get first index value from an arraylist and when the same method is called next time i want to get the second index value from the same arraylist...how can i do that? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; namespace roseapp2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } public ArrayList MPN = new ArrayList(); public string[,] Modems = new string[,] { {"Apple", "Banana", "81563840", "Damson"}, {"Elderberry", "Fig", "81547907", "Huckleberry"}, {"Indian Prune", "Jujube", "98764343322", "Lime"} }; public string arrayValue; private void button1_Click_1(object sender, EventArgs e) { // getphnum(); RoundRobin(); } private int z = 0; public void RoundRobin() { if (Modems == null) throw new ArgumentNullException("Modem"); if (Modems.Length < 0) return; //int Count = 0; int i; int x = Modems.Length/4; MessageBox.Show(Convert.ToString(x)); for (i = 0; i < x; i++) { string a = Modems[i, 2]; MessageBox.Show(a); arrayValue = a; MPN.Add(arrayValue); } for (int a = 0; a < MPN.Count; a++) { MessageBox.Show("ARRAY VALUE for index "+a+" "+Convert.ToString(MPN[a])); } } public void getphnum() { z++; MessageBox.Show(Convert.ToString(z)); } } } in this when the getphnum() is called one time i wnat to get firts index value(ie index 0 ph number)ie MPN arraylist.ANd when next time when getphnum () is called i want to get index 1 value from arraylist MPN.(ie the same arraylist from which i call my first array index value).. can somebody help meeeeeeeeeeee :| :|
-
when a method is called i want to get first index value from an arraylist and when the same method is called next time i want to get the second index value from the same arraylist...how can i do that? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; namespace roseapp2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } public ArrayList MPN = new ArrayList(); public string[,] Modems = new string[,] { {"Apple", "Banana", "81563840", "Damson"}, {"Elderberry", "Fig", "81547907", "Huckleberry"}, {"Indian Prune", "Jujube", "98764343322", "Lime"} }; public string arrayValue; private void button1_Click_1(object sender, EventArgs e) { // getphnum(); RoundRobin(); } private int z = 0; public void RoundRobin() { if (Modems == null) throw new ArgumentNullException("Modem"); if (Modems.Length < 0) return; //int Count = 0; int i; int x = Modems.Length/4; MessageBox.Show(Convert.ToString(x)); for (i = 0; i < x; i++) { string a = Modems[i, 2]; MessageBox.Show(a); arrayValue = a; MPN.Add(arrayValue); } for (int a = 0; a < MPN.Count; a++) { MessageBox.Show("ARRAY VALUE for index "+a+" "+Convert.ToString(MPN[a])); } } public void getphnum() { z++; MessageBox.Show(Convert.ToString(z)); } } } in this when the getphnum() is called one time i wnat to get firts index value(ie index 0 ph number)ie MPN arraylist.ANd when next time when getphnum () is called i want to get index 1 value from arraylist MPN.(ie the same arraylist from which i call my first array index value).. can somebody help meeeeeeeeeeee :| :|
Take a static class variable and initialize it with the index of array and when you call the method again just add 1 to that variable i.e use that variable like a counter hope this helps sorry for the bad english. If thats not what you want then let me know
-
when a method is called i want to get first index value from an arraylist and when the same method is called next time i want to get the second index value from the same arraylist...how can i do that? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; namespace roseapp2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } public ArrayList MPN = new ArrayList(); public string[,] Modems = new string[,] { {"Apple", "Banana", "81563840", "Damson"}, {"Elderberry", "Fig", "81547907", "Huckleberry"}, {"Indian Prune", "Jujube", "98764343322", "Lime"} }; public string arrayValue; private void button1_Click_1(object sender, EventArgs e) { // getphnum(); RoundRobin(); } private int z = 0; public void RoundRobin() { if (Modems == null) throw new ArgumentNullException("Modem"); if (Modems.Length < 0) return; //int Count = 0; int i; int x = Modems.Length/4; MessageBox.Show(Convert.ToString(x)); for (i = 0; i < x; i++) { string a = Modems[i, 2]; MessageBox.Show(a); arrayValue = a; MPN.Add(arrayValue); } for (int a = 0; a < MPN.Count; a++) { MessageBox.Show("ARRAY VALUE for index "+a+" "+Convert.ToString(MPN[a])); } } public void getphnum() { z++; MessageBox.Show(Convert.ToString(z)); } } } in this when the getphnum() is called one time i wnat to get firts index value(ie index 0 ph number)ie MPN arraylist.ANd when next time when getphnum () is called i want to get index 1 value from arraylist MPN.(ie the same arraylist from which i call my first array index value).. can somebody help meeeeeeeeeeee :| :|
merryjoy000 wrote:
in this when the getphnum() is called one time i wnat to get firts index value(ie index 0 ph number)ie MPN arraylist.ANd when next time when getphnum () is called i want to get index 1 value from arraylist MPN
Do you mean a counter? If yes, use "static“ for z var.
:) I Love KongFu~