Hi
I want my list to have only unique values
String.Join(“;”, Array.ConvertAll(DT.Select().Distinct().ToArray(), Function(row) row(“Order”).ToString))
I tried to use distinct but still doesn’t work
Hi
I want my list to have only unique values
String.Join(“;”, Array.ConvertAll(DT.Select().Distinct().ToArray(), Function(row) row(“Order”).ToString))
I tried to use distinct but still doesn’t work
Use this snippet
String.Join(";", (From row In DT.AsEnumerable() Select row.Field(Of String)("Order")).Distinct().ToArray())
no it doesn’t work
It’s working. May be you are expecting something else.
Input datatable:
Output:
See the unique values from Order columns are printed.
then give details on what is the input and what is the failing output
In General we recommend also to trim/harmonize the values
e.g. getting a flat string like:
String.Join(";", dtData.AsEnumerable().Select(Function (x) x("Order").toString.Trim).Distinct())
Please try this
string.Join(";",Dt.AsEnumerable.GroupBy(function(x) x("Order").ToString.Trim.ToLower).Select(function(x) x.First(function(y) y("Order").ToString)))
Could directly use select with groupby expression and then distinct…but wanted to preserve atleast one format
Cheers