fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public List<int> MyList { get; set; }
  8.  
  9.  
  10. public static void Main()
  11. {
  12. Test t = new Test();
  13. t.MyList = new List<int>();
  14.  
  15. t.MyList.Add(-1);
  16. t.MyList.Add(0);
  17. t.MyList.Add(1);
  18. t.MyList.Add(2);
  19.  
  20. int siteNumbers = t.MyList.Where(i => i != -1)
  21. .Select(x => x)
  22. .Distinct()
  23. .Count();
  24.  
  25. Console.WriteLine(siteNumbers);
  26. }
  27. }
Success #stdin #stdout 0.04s 24056KB
stdin
Standard input is empty
stdout
3