fork download
  1. using static System.Console;
  2. using System.Linq;
  3. using System.Diagnostics;
  4.  
  5. public class Program {
  6. public static void Main() {
  7. var texto = "João da Maquipe";
  8. var parte = texto.Substring(0, texto.IndexOf(' '));
  9. WriteLine(parte);
  10. var first = texto.Split(' ').FirstOrDefault();
  11. WriteLine(first);
  12. var tempo = new Stopwatch();
  13. for (var i = 0; i < 10000; i++) {
  14. parte = texto.Substring(0, texto.IndexOf(' '));
  15. }
  16. WriteLine(tempo.ElapsedTicks);
  17. tempo.Restart();
  18. for (var i = 0; i < 10000; i++) {
  19. first = texto.Split(' ').FirstOrDefault();
  20. }
  21. WriteLine(tempo.ElapsedTicks);
  22. }
  23. }
  24.  
  25. //https://pt.stackoverflow.com/q/82070/101
Success #stdin #stdout 0.03s 20048KB
stdin
Standard input is empty
stdout
João
João
0
42906