Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: C#  |  size: 1.02 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. List<BarcodeLibrary.BarcodeDataResponse> lstBarcodes = bcFunc.GetBarcodes();
  2.  
  3.             Dictionary<string, int> countedCodes = new Dictionary<string, int>();
  4.             foreach (var barcode in lstBarcodes)
  5.             {
  6.                 if (countedCodes.ContainsKey(barcode.Code))
  7.                 {
  8.                     countedCodes[barcode.Code]++;
  9.                 }
  10.                 else
  11.                 {
  12.                     countedCodes.Add(barcode.Code, 1);
  13.                 }
  14.             }
  15.  
  16.             List<KeyValuePair<string, int>> list = countedCodes.ToList();
  17.             string csv = String.Join(",", list.Select(x => x.ToString()).ToArray());
  18.  
  19.  
  20.             StringBuilder sbResult = new StringBuilder();
  21.             foreach (BarcodeLibrary.BarcodeDataResponse bcItem in lstBarcodes)
  22.             {
  23.                 sbResult.AppendLine(bcItem.ToFormattedString());
  24.             }
  25.  
  26. /* OUTPUT IS  
  27.  
  28. [978140274228651295, 6],[978087701878090000, 1],[978097443930351995, 1],[9780974439303, 1],[9781402742286, 5]
  29.  
  30. */