المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Enumerate a Listbox



C# Programming
09-19-2009, 07:11 AM
I want to Iterate thru a listBox and write the strings to a file.
I have the following code that worked in VS 2005 but does not compile in VS 2008

StreamWriter f = new StreamWriter(fn);
IEnumerator eEnum = this.mylistBox.Items.GetEnumerator();
if (eEnum != null)
while (eEnum.MoveNext())
f.WriteLine((String) eEnum.Current);
f.Close();

In VS 2008 I get a compile error saying

Using the generic type 'System.Collections.Generic.IEnumerator' requires '1' type arguments

Can someone explain ?