How to convert object to IEnumerable

I have been trying to clone an array using Clone method.As Clone method returns object i could not iterate thru for each loop.

Attached the workflow where I got the issue Flowchart_Array_Clone.xaml (13.2 KB)

I have tried to search for the solution using Google and UiPath forum. But I could not get the solution. Could you please help me resolve the issue.

In UIpath forum , I got the related link How to cast Object to IEnumerable for looping in For each? , but I could not understand how to use trycast function.

Is there any particular reason you want to use Clone method? whats is your objective, is it to create a copy of the array?

If you want to simply create a copy, you could use
clone_dArr = dArr.ToList().ToArray()

1 Like

Thank for the response.
Just I want to learn how the clone method works in UiPath. Is there a way to convert object to IEnumerble ?

1 Like

Welcome back to uipath community
Basically when we are trying to clone a array the output variable is of type object, which means a shallow copy of array
public object Clone ();
— but if we check the type of that output variable it would be like, mention as dArr.GetType.ToString and the output would be System.Double[ ]
And while referring to for each loop the type argument be like object
For more details

Cheers @rtallapudi

I dont understand why you try to convert an array of double to an object. But in your xaml i understood than u wish to print it.

You can use CType for convert your object to an array again:

CType(clone_dArr, Double())


CType(clone_dArr, Double()).AsEnumerable()



here you go its resolved (2.9 KB)
the actual reason is for each loop will take input as ienumerable and to convert a object to ienumerable we need to mention as
ctype(Myobjtype, totype)
that is

Cheers @rtallapudi


@inf_L and @Palaniyappan .Both the solutions worked.

Thank you so much both, for your time .

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.