// public within the private implementation // thus, private within ListBoxTest public ListBoxEnumerator(ListBoxTest currentListBox) { // a particular ListBoxTest instance is // passed in, hold a reference to it // in the member variable currentListBox. this.currentListBox = currentListBox; index = -1; }
public void Run() { // create a new listbox and initialize ListBoxTest currentListBox = new ListBoxTest("Hello", "World"); // add a few strings currentListBox.Add("Who"); currentListBox.Add("Is"); currentListBox.Add("John"); currentListBox.Add("Galt"); // test the access string subst = "Universe"; currentListBox[1] = subst; // access all the strings foreach (string s in currentListBox) { Console.WriteLine("Value: {0}", s); } }