string barcodes = string.Join(",",
result.data
.Where(a => !string.IsNullOrEmpty(a.BarcodeValue)) // ignore null/empty
.Select(a =>
{
// Try to parse only numeric barcodes
if (long.TryParse(a.BarcodeValue, out long num))
{
// Return exactly 13 digits
return num.ToString().PadLeft(13, '0');
}
return null; // reject invalid ones
})
.Where(b => b != null && b.Length == 13) // keep only 13-digit results
);
Ex:
[
{ "BarcodeValue": "0507510108257" },
{ "BarcodeValue": "0001234" },
{ "BarcodeValue": "7890" },
{ "BarcodeValue": "ABC123" } // invalid
]
Sign up here with your email
ConversionConversion EmoticonEmoticon