Add an Additional Value in Item Index of Array

Hello Everyone,

I’ve question… How to add an additional value (string type) in item specific index of array (int32 type)?

The scenario is:

  • Additional Value: “SAME”
  • Type Array Var: Int32[] → [10,20,30]

One of final result example is: [10 | SAME, 20, 30]

Anyone can help me?

Thank in Advanced & Regards,
Brian

Hi,

We cannot add string value to Int32 array.

Can you share what you want to achieve at the end?

Regards,

1 Like

Oh right I just remembered. I’ve change the scenario like this:

The scenario is:

  • Type Additional Value: Int32 → 100, 200, 300 (in each different variable)
  • Type Array Var: Int32[] → [10,20,30]

One of final result example is: [10, 100, 20, 200, 30, 300]

How about this?

Hi,

If it’s mandatory to merge array as the above order, the following will help.

arr.Zip(arrAdd, Function(x,y) {x,y}).SelectMany(Function(x) x).ToArray()

If it’s not important about order, we can use Array.Copy or Concat method.

Regards,

1 Like

Hello @henokhbrian

  1. Array is a fixed-sized structure, you can not add items to it.
  2. To achieve your implementation, you can use the collection. By using collection you can add, insert items at specific position or delete them as size is dynamic here.
1 Like

That isn’t mandatory, just one of my experiment to validating the data.
Your help is very useful for me, thank you very much. :innocent:

Cheers

Hello,

Thank you for your help. I will definitely try that :handshake:

Regards,
Brian

Hi,

That isn’t mandatory, just one of my experiment to validating the data.

Alright. The following will work, FYI

arr.Concat(arrAdd).ToArray()

Regards,

2 Likes