Add comma between values by using Linq

Hi all, I have a linq command that removes duplicate values, this works so far. What is new is that I need a comma after the OrderID, how can I achieve this?

That means if the input OrderID is “0815” I want to have “0815,” in the output.

(From d In DT_Input.AsEnumerable
Group d By k=String.Join(“,”,d(“Order_Number”).toString.Trim) Into grp = Group
Let ra = New Object(){grp.First()(1)}
Select r = DT_Clone.Rows.Add(ra)).CopyToDataTable

Hi @NHoe ,

Could you Provide More details as to what are the Other Columns present in the Datatable or maybe post the Schema of the Datatable?

Hi,

The following code will add comma in OrderId column.

dt.AsEnumerable.ToList.ForEach(
Sub(r)
    r("OrderId")=r("OrderId").ToString()+","
End Sub
)

Sample20221111-5.zip (2.7 KB)

Regards,

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