fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class P
  6. {
  7. struct DataItem
  8. {
  9. public System.DateTime time;
  10. public int number;
  11. }
  12.  
  13. public static void Main(string[] args)
  14. {
  15. var ItemList = new DataItem[] {} ;
  16. var groups = ItemList
  17. .GroupBy(item => new { item.time.Hour, item.time.Minute });
  18. var sums = groups
  19. .ToDictionary(g => g.Key, g => g.Sum(item => item.number));
  20.  
  21.  
  22. // lookups now become trivially easy:
  23.  
  24. int partialByTimeSlot = sums[new {Hour=23,Minute=10}];
  25. }
  26. }
  27.  
Runtime error #stdin compilation error #stdout 0.02s 40032KB
stdin
Standard input is empty
compilation info
prog.cs(24,21): warning CS0219: The variable `partialByTimeSlot' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
stdout
Standard output is empty