I want to print string data side by side in Datatable

Hello everyone,

The number of rows in this datatable is not fixed.

image

I want it to save “resource” data side by side to “fullResource” every time the loop returns.

For example, there are 3 data.

first Max
second Lewis
third Valtteri

What I want is for him to write " Max - Lewis - Valtteri "

Thanks !!

Hi @MrKezay

Use the below steps to achieve without looping!

Use assign

NewValueArrayStr =readDt.AsEnumerable.Select(function (row) row("YourColumnnameOrIndex).ToString).ToArray

Write line

String.Join("-",NewArrayVar)

Regards

1 Like

Use Output data table and store the value in “val” string variable.

string.Join("-",val.Split(Environment.NewLine.ToCharArray))

Regards,
Arivu

1 Like

Hi,

Create a variable before for each loop to count the data table rows since it is not fixed.

DTRwoCount = dt.rows.count

if condition → currentindex = DTrowcount

then part:

full resource = full resource + resource

else part

full resource = full resource + resource + “-”

i think the above flow would give you the result. thanks.

if you do not go for linq the above logic would help. if you want go with linq please follow our forum members suggestion. thanks.

1 Like