Hi

Remove the leading zero(s) before joining, you can parse to a number and back to string.

 string barcodes = string.Join(",",

    result.data.Select(a =>

    {

        if (long.TryParse(a.BarcodeValue, out long num))

            return num.ToString(); // removes leading zeros

        return a.BarcodeValue;     // fallback if not numeric

    })

);


Console.WriteLine(barcodes);



will convert
"0507510108257", "0001234", "7890"


"507510108257,1234,7890"

Previous
Next Post »