
Untitled
By: a guest on
May 1st, 2012 | syntax:
C# | size: 1.02 KB | hits: 19 | expires: Never
List<BarcodeLibrary.BarcodeDataResponse> lstBarcodes = bcFunc.GetBarcodes();
Dictionary<string, int> countedCodes = new Dictionary<string, int>();
foreach (var barcode in lstBarcodes)
{
if (countedCodes.ContainsKey(barcode.Code))
{
countedCodes[barcode.Code]++;
}
else
{
countedCodes.Add(barcode.Code, 1);
}
}
List<KeyValuePair<string, int>> list = countedCodes.ToList();
string csv = String.Join(",", list.Select(x => x.ToString()).ToArray());
StringBuilder sbResult = new StringBuilder();
foreach (BarcodeLibrary.BarcodeDataResponse bcItem in lstBarcodes)
{
sbResult.AppendLine(bcItem.ToFormattedString());
}
/* OUTPUT IS
[978140274228651295, 6],[978087701878090000, 1],[978097443930351995, 1],[9780974439303, 1],[9781402742286, 5]
*/