fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. [Flags]
  7. public enum IntFlags
  8. {
  9. A = 1 << 0,
  10. B = 1 << 1,
  11. C = 1 << 2,
  12.  
  13. AAndB = A | B
  14. }
  15.  
  16. public static IntFlags Set( IntFlags values, IntFlags target )
  17. {
  18. if (!Enum.GetValues(typeof(IntFlags)).Cast<IntFlags>().Contains(values))
  19. throw new ArgumentException();
  20.  
  21. Console.WriteLine( "values: " + values + ", target: " + target );
  22.  
  23. return target | values;
  24. }
  25.  
  26. public static void Main()
  27. {
  28.  
  29. Set(IntFlags.A | IntFlags.B, 0);
  30. Set(0, 0);
  31. // your code goes here
  32. }
  33. }
Runtime error #stdin #stdout #stderr 0.06s 37008KB
stdin
Standard input is empty
stdout
values: AAndB, target: 0
stderr
Unhandled Exception: System.ArgumentException: Value does not fall within the expected range.
  at Test.Set (IntFlags values, IntFlags target) [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Value does not fall within the expected range.
  at Test.Set (IntFlags values, IntFlags target) [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0