Convert arraylsit to string


#1

Cna some pelase help me on How to print Values in Array variable as string.
As I created an Array varaible and it is storing the values as a list and I wanted to print those values.


#2

@sambana_karunakar

string.join(",",ArrayVariable)
This will prient all the elements of your array seperated by comma

Regards,
Mahesh


#3

@MAHESH1 I need like one by one list not in same line, how to do that


#4

@sambana_karunakar

string.Join(Environment.NewLine,Array_Variable)

Regards,
Mahesh


#5

@MAHESH1 Sorry some thing is missed not getting expcted results. let me tell you,
I have an CSV file and in with 2ncloumn has many and only few row are has data remaining are empty. and I need the non empty cell vaules to store in a Array varaible and I wanted to print the those stored values in a mail body. this is my requirement

please check and help me at print all values in one mail as of now gettiing each values in each mails let say if there are five cells has data it is sending five mails. i need five values to print in one mail. if put the outlook activity outside of the for each loop it is sending only one mail with printing last cell value.(like fifth value out of five).


#6

@sambana_karunakar
What is the datatype of list you are using

Regards,
Mahesh


#7

list is string


#8

@sambana_karunakar

Create a Variable of ListOf Strings List_Names
Use Add to Collections Activity
Add row(“Column-1”).ToString to collections i.e List_Names

At last outside for each
strA=string.Join(Environment.NewLine,List_Names)

Regards,
Mahesh


#9

@sambana_karunakar
If its a string then definitely it will contain only the last value.

Regards,
Mahesh


#10

Hi @sambana_karunakar,

First get the column value for. The datatable to array.(use linq to get the column value to array)
@MAHESH1 try linq query to get all the value

Then use
string.Join(Environment.NewLine,Array_Variable)

If you use for each Loop each time you will get mail with single value

Regards,
Arivu


#11

@sambana_karunakar
Let us take you are having a datatable dta
No need to use foreach row
List A-List of Strings-Use in Assign Activity

ListA=(From p in dta.Select()
where not string.IsEmpty(Convert.ToString(p.Item(“Column-1”)))
Select Convert.ToString(p.Item(“Column-1”))).ToList()

string a=string.join(Environment.NewLine,ListA)

Regards,
Mahesh


#12

Good work @MAHESH1,

@sambana_karunakar use this code

Small change

string a=string.join(Environment.NewLine,ListA.ToArray())

Pass this string value to mail and send it

Regards,
Arivu


#13

@arivu96
I think even if its list also it will join.

Regards,
Mahesh


#14

Yes correct. I did’t noticed. :slight_smile:


#15

@arivu96

No problem :grinning:

Regards,
Mahesh


#16

Hey I am getting error inthis can you correct it again

(From p in dt.Select()
where not string.IsEmpty(Convert.ToString(p.Item(“Column-1”))
Select Convert.ToString(p.Item(“Column-1”))).ToList()


#17

@sambana_karunakar
Replace dt with your datatable variable

Regards,
Mahesh


#18

dt is my data varaible


#19

@sambana_karunakar
Can you share the screen shot of error
Regards
Mahesh


#20

please chcek