I need to convert from
object {object[]}
to
System.Collections.Generic.List<int>
Inside each element in the object array there is a object {int}
element.
I got this structure from a COM dll.
I was wondering how is the easiest way to do that. Thanks in advance!
try
List<int> intList = objectArray.Cast<int>().ToList();
List<Int> ObjToList(object[] objects)
{
List<int> intList = new list<int>();
foreach (object o in objects)
{
intList.Add((int)o);
}
return intList;
}
be very sure that all your objects in the array are of type int to avoid problems
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With