fork download
  1. using System;
  2.  
  3. public class Program {
  4. public static void Main() {
  5. var (deuCerto, resultado) = "123".TryParseInt32();
  6. if (deuCerto) Console.WriteLine(resultado);
  7. }
  8. }
  9.  
  10. namespace System {
  11. public static class StringExt {
  12. public static (bool ok, int result) TryParseInt32(this string text) => (int.TryParse(text, out var result), result);
  13. }
  14. }
  15.  
  16. //https://pt.stackoverflow.com/q/195460/101
Success #stdin #stdout 0.02s 16000KB
stdin
Standard input is empty
stdout
123