# Two Array in a string i.e. System.String\[\]\[\]

**URL:** <https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [April 23, 2023, 4:13pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334 "2023-04-23T16:13:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![YangYang](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@YangYang](https://forum.uipath.com/u/YangYang)\
**Post date:** [April 23, 2023, 4:13pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/1 "2023-04-23T16:13:15Z")

</div>

Hi there,  
Need help in getting the output as  
ABC,Lim  
Sammy,Tan  
which is FirstName(0)+“,”+LastName(0) and next new line as FirstName(1)+“,”+LastName(1)  
But i need the counter to be dynamic cos it can be more than 2

two variables  
FirstName = {“ABC”,“Sammy”}  
LastName = {“Lim”,“Tan”}  
Output variable type is String  
What should the flow and syntax?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/0/d/f/0dfc020f36f29e43578e207f600264cf2ecde782.png)

Thank you

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [April 23, 2023, 4:18pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/2 "2023-04-23T16:18:42Z")

</div>

@YangYang

Please try this

1. Use for loop on firstname and change the type argument to string
2. Assign a variable to index in for loop properties
3. Use inside loop to get as you need `currentItem + "," + lastname(indexvar)`

And not sure why you need string array of array…

Cheers

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 23, 2023, 4:26pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/3 "2023-04-23T16:26:31Z")

</div>

> [@YangYang](#):
>
> FirstName = {“ABC”,“Sammy”}  
> LastName = {“Lim”,“Tan”}

Hi @YangYang ,

Assuming you have Equal number of String items in both of the arrays and they are to be matched 1:1, then we can use the below Expression :

```auto
Output = (From i in Enumerable.Range(0,FirstName.Count) Select FirstName(i)+","+LastName(i)).ToArray

```

The above Expression results in an Array of String type, so you have to change the `Output` variable type also to the same.

Also, Maybe try renaming variables `FirstName` to `FirstNamesList`, just so it is marking it as a list.

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [April 23, 2023, 4:29pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/4 "2023-04-23T16:29:01Z")

</div>

Hi

Hope the below steps would help you resolve this

1. Use a For each activity and pass FirstName as input variable and change the type argument as String

2. Inside the loop use a ADD TO COLLECTION or APPEND ITEM TO COLLECTION activity where in collection mention the output variable name and item property mention as  
**item.ToString+”,”+LastName(Array.IndexOf(FirstName, item.ToString)).ToString+Environment.NewLine**

3. This will combine those two names with NewLine before to the next full name

4. Make sure the output variable mentioned in the activity is of type like this  
System.Collections.Generic.List  
You can browse this type in browse type in variable panel

You can convert this anytime to array by just mentioning like this assign activity

**Arrayvariable = listvariable.ToArray()**

Cheers @YangYang

---

<div class="post-metadata">

**Author:** ![YangYang](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@YangYang](https://forum.uipath.com/u/YangYang)\
**Post date:** [April 23, 2023, 4:42pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/5 "2023-04-23T16:42:14Z")

</div>

Hi Palaniyappan,

i would like to have the output as  
ABC Lim  
Sammy Tan

 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/4/0/540a88219f3d4bec1646b34e3d042e5b0e002b70.png)

---

<div class="post-metadata">

**Author:** ![YangYang](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@YangYang](https://forum.uipath.com/u/YangYang)\
**Post date:** [April 23, 2023, 4:51pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/6 "2023-04-23T16:51:35Z")

</div>

Hi Arpan,

Didn’t fetch the result i want.  
kindly advise what went wrong

 ![image](https://global.discourse-cdn.com/uipath/original/4X/b/b/b/bbb9234a09588c096eeffa97fbd58d2a4f2ddbba.png)

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [April 23, 2023, 5:00pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/7 "2023-04-23T17:00:22Z")

</div>

Fine

If you would like to print inside the for each activity itself with a writeline then skip ADD TO COLLECTION activity and just mention like this in a assign activity

**str\_output = item.ToString+”,”+LastName(Array.IndexOf(FirstName, item.ToString)).ToString**

Where str\_output is a string variable defined in variable panel with default value as string.Empty

Then use a writeline activity next to this assign and mention as str\_output.ToString

This can be mentioned even outside the for each loop and u get the same output with each full name one below the another  
But for that the assign activity inside the for each loop should be like this

**str\_output = item.ToString+”,”+LastName(Array.IndexOf(FirstName, item.ToString)).ToString** Environment.NewLine+str\_output\*\*

If you want to have it as a list output variable Then use this assign and writeline activity next to add to collection activity inside the loop

Cheers @YangYang

---

<div class="post-metadata">

**Author:** ![YangYang](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@YangYang](https://forum.uipath.com/u/YangYang)\
**Post date:** [April 23, 2023, 5:12pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/8 "2023-04-23T17:12:36Z")

</div>

Thank You Palaniyappan  
Got it.

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 23, 2023, 6:35pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/9 "2023-04-23T18:35:13Z")

</div>

@YangYang ,

To print the values, You would have to use a String Join operation in the write line activity like below:

```auto
String.Join(Environment.NewLine,Output)

```

---

<div class="post-metadata">

**Author:** ![YangYang](https://avatars.discourse-cdn.com/v4/letter/y/a3d4f5/32.png) [@YangYang](https://forum.uipath.com/u/YangYang)\
**Post date:** [April 24, 2023, 12:54pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/10 "2023-04-24T12:54:20Z")

</div>

Hi Arpan,

It works perfectly.  
Thanks alot.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [April 27, 2023, 12:54pm UTC](https://forum.uipath.com/t/two-array-in-a-string-i-e-system-string/538334/11 "2023-04-27T12:54:25Z")

</div>

Closed on April 27, 2023, 12:54pm UTC

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