fork download
  1. using static System.Console;
  2.  
  3. public class Program {
  4. public static void Main() {
  5. WriteLine(BtnSoma_Click(ReadLine(), ReadLine()));
  6. }
  7. private static string BtnSoma_Click(string txtNum1, string txtNum2) {
  8. if (!int.TryParse(txtNum1, out var valor1) || !int.TryParse(txtNum2, out var valor2)) {
  9. WriteLine("Pelo menos um dos valores é inválido");
  10. return null;
  11. }
  12. return (valor1 + valor2).ToString();
  13. }
  14. }
  15.  
  16. //https://pt.stackoverflow.com/q/350190/101
Success #stdin #stdout 0.02s 16088KB
stdin
10
stdout
Pelo menos um dos valores é inválido