Friday 20 June 2014

How to convert from ArrayList to array in net

Posted by Саша 02:33, under | No comments


How to convert from ArrayList to array in .net? How to convert from ArrayList to array in .net?

I have a class idnamepair which contains 2 members, int id and String^ name;
I have a ArrayList created with this class's objects.
How can I convert it to array?


Other Answers:




Here's how in C#.

ArrayList MyArrayList = new ArrayList();
MyArrayList.Add( new idnamepair() ); //added first instance of your class
MyArrayList.Add( new idnamepair() ); //added another instance of your class

idnamepair[] MyArray;
MyArray = MyArrayList.ToArray( typeof(idnamepair) );

hope this helps









0 коммент.:

Post a Comment