fork download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. public class Test
  7. {
  8.  
  9.  
  10. public static void Main()
  11. {
  12. string s="aa bb cc dd ee ff gg hh ii kk";
  13. var fifthBlankIndex = s.Select((c, index) => new{ c, index })
  14. .Where(x => Char.IsWhiteSpace(x.c))
  15. .ElementAtOrDefault(4);
  16.  
  17. int result = -1;
  18. if(fifthBlankIndex != null)
  19. result = fifthBlankIndex.index;
  20. Console.WriteLine(result);
  21. }
  22. }
Success #stdin #stdout 0.03s 34000KB
stdin
Standard input is empty
stdout
14