fork download
  1. using System;
  2.  
  3. public class Test {
  4.  
  5. public static void Main() {
  6. var test = new AlwaysTrue();
  7.  
  8. if (test) {
  9. Console.WriteLine("This is true!");
  10. }
  11.  
  12. if (test == true) {
  13. Console.WriteLine("This is also true!");
  14. }
  15.  
  16. if (test == false) {
  17. Console.WriteLine("This can't possibly be true!");
  18. }
  19.  
  20. if (test != true) {
  21. Console.WriteLine("Now you're just being silly");
  22. }
  23.  
  24. if (test != false) {
  25. Console.WriteLine("wut");
  26. }
  27. }
  28.  
  29. class AlwaysTrue {
  30. public AlwaysTrue() { }
  31.  
  32. public static bool operator ==(AlwaysTrue me, bool other) {
  33. return true;
  34. }
  35.  
  36. public static bool operator !=(AlwaysTrue me, bool other) {
  37. return true;
  38. }
  39.  
  40. public static implicit operator bool(AlwaysTrue me) {
  41. return true;
  42. }
  43. }
  44. }
Success #stdin #stdout 0.01s 131072KB
stdin
Standard input is empty
stdout
This is true!
This is also true!
This can't possibly be true!
Now you're just being silly
wut