sde
Well-known member
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?
any insight would be greatly appreciated.
thanks
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?
Code:
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;
}
thanks