fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. string str = "fnGetDate('d',-1+ cint(cbool(DatePart('w',Date())<=2)) + cint(cbool(DatePart('w',Date())=2)))";
  8. int parLevel = 0;
  9. List<string> arguments = new List<string>();
  10. string currentString = String.Empty;
  11.  
  12. foreach (char t in str)
  13. {
  14. switch (t)
  15. {
  16. case '(':
  17. if (t == '(') parLevel++;
  18. break;
  19. case ')':
  20. if (t == ')') parLevel--;
  21. break;
  22. case ',':
  23. if (parLevel > 1) continue;
  24.  
  25. arguments.Add(currentString);
  26. currentString = String.Empty;
  27. break;
  28. default:
  29. if (parLevel == 0) continue;
  30.  
  31. currentString += t;
  32. break;
  33. }
  34. }
  35. if (!String.IsNullOrEmpty(currentString)) arguments.Add(currentString);
  36.  
  37. for (int i = 0; i < arguments.Count; i++)
  38. Console.WriteLine("Argument {0}: {1}", i, arguments[i]);
  39. }
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(9,9): error CS0246: The type or namespace name `List' could not be found. Are you missing `System.Collections.Generic' using directive?
prog.cs(25,21): error CS0841: A local variable `arguments' cannot be used before it is declared
prog.cs(35,51): error CS0841: A local variable `arguments' cannot be used before it is declared
prog.cs(37,29): error CS0841: A local variable `arguments' cannot be used before it is declared
prog.cs(38,55): error CS0841: A local variable `arguments' cannot be used before it is declared
Compilation failed: 5 error(s), 0 warnings
stdout
Standard output is empty