fork(1) download
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var withSpaces = FailureDescription.MemoryFailureTest.ToStringWithSpaces();
  11. Console.WriteLine(withSpaces);
  12. }
  13. }
  14.  
  15. public static class EnumExtensions
  16. {
  17. public static string ToStringWithSpaces(this Enum value)
  18. {
  19. var withSpaces =
  20. Regex
  21. .Matches(value.ToString(), @"([A-Z][a-z]+)(?=[A-Z]|$)")
  22. .Cast<Match>()
  23. .Select(m => m.Groups[1].Value)
  24. .Aggregate((str, next) => (str = str + " " + next));
  25. return withSpaces;
  26. }
  27. }
  28.  
  29. public enum FailureDescription
  30. {
  31. MemoryFailureTest,
  32. Fragmentation,
  33. SegmentationFault
  34. }
Success #stdin #stdout 0.1s 24664KB
stdin
Standard input is empty
stdout
Memory Failure Test