Storing multiple values in a string

Hi,

I having a string variable name as “str”, am using it under for loop. So, during each loop “str” variable will be getting a value, I want to save all string data in the same or in single string variable with space separated. Then I will be passing the variable value into my first column of datatable. How can i do that?

@monish06 You can use an Assign like this :
str = str+" "

This Should Work, Try it out :sweat_smile:

5 Likes

@monish06

Step 1: Initialize “str” variable outside for loop
Step 2: str = str + " " + newValueToAppend
Step 3: Outside for loop assign value of str to datatable

Cheers

3 Likes

1)We can use StringBuilder for this
2)Using Assign and append the value in loop

Initially String1,String2 will be blank

inside loop
string1 = string1 +" "+string2

end of loop

string1=“”

clear it if required .

2 Likes

Inside loop first check whether the index is 0 or not
If index is 0 assign Str = Variable.
Else assign Str = Str+" "+Variable.
At last Str will have all the variable value with space separated.

Then to add str variable to first column of datable use assign activity
Datatable.rows(RowNumber)(0) = Str