sde Posted January 9, 2004 Posted January 9, 2004 I am writting a method which returns an array of phone numbers. the phone numbers are their own object. for reasons beyond my control, i need to build the array of phone numbers in an array list. i now have an ArrayList of Phone objects. is it possible to convert the ArrayList to a Phone array without running a foreach loop? public Phone[] GetPhoneNumbers(string CustomerID) { ... ArrayList PhoneArrayList = new ArrayList(); while(reader.Read) { Phone phoneItem = new Phone(); phoneItem.AreaCode = reader[0].ToString(); phoneItem.Prefix = reader[1].ToString(); phoneItem.Suffix = reader[2].ToString(); phoneItem.Ext = reader[3].ToString(); PhoneArrayList.Add(phoneItem); } Phone[] PhoneNumbers = new Phone[] { }; // here is where i need to convert the ArrayList // to Phone[] array return PhoneNumbers; }any insight would be greatly appreciated. thanks Quote codenewbie
Administrators PlausiblyDamp Posted January 9, 2004 Administrators Posted January 9, 2004 Have a look at PhoneArrayList.CopyTo() and it's overloads - one of them may work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.