Need help on arrays... for the below question

need help on this…

Array1 = {1, 2, 3, 0, 5, 6, 0, 0, 0, 9, 7}

Array2 = {8, 0, 0, 4}

Your Output array must be:
{1, 2, 3, 4, 5, 6, 7, 8, 9}

1 Like

You can join the two arrays as a string, simply by β€œ+” operator

To convert array to string:

String.Join(β€œ,”,array1)

Then after you have ont string with all the values from both array. You can replace β€œ,0” with β€œβ€
newStringCreated.Replace(β€œ, 0”,β€œβ€)

if you need the string to be converted back to array, you can use

newStringCreated.Split(β€œ,”)

similar logic you can do via datatable but this is more cleaner approach.

Hope this helps!

Hi

Let’s go with a single expression in a assign activity like this

arr_final = Array.Sort(Array1.Where(Function(a) NOT a.ToString.Contains(β€œ0”)).ToArray().Concat(Array2.where(Function(b) NOT b.ToString.Contains(β€œ0”))))

In separate

Array1.Where(Function(a) NOT a.ToString.Contains(β€œ0”)).ToArray()

This will delete 0 in a array1

Array2.where(Function(b) NOT b.ToString.Contains(β€œ0”)))

This will delete 0 in array2

Concat() - will add these two arrays

Array.Sort() - this will sort the array

Hope this would help you resolve this issue

To get that as a string and show in message box

String.Join(β€œ-β€œ,arr_final)

Cheers @Sudheer_Kumar1

1 Like

Hi,

Another solution:

result = array1.Union(array2).Where(Function(i) i>0).OrderBy(Function(i) i).ToArray()

Regards,

1 Like

@Yoichi thanks for your reply i am unable to show array result in message box it is showing as System.Int32

Hi

Can you try the following?

String.Join(",", intArray)

Regards,

1 Like

I have updated in the previous comment which has the complete step to solve this
@Sudheer_Kumar1

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