fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static int TrueCount(params bool[] booleans)
  7. {
  8. return booleans.Count(b => b);
  9. }
  10.  
  11. public static void Main()
  12. {
  13. bool bool1 = true;
  14. bool bool2 = false;
  15. bool bool3 = true;
  16. bool onlyOneTrue = TrueCount(bool1,bool2,bool3)==1;
  17. Console.WriteLine("Only one true? " + onlyOneTrue);
  18. }
  19. }
Success #stdin #stdout 0.02s 33888KB
stdin
Standard input is empty
stdout
Only one true? False