jeudi 13 juillet 2017

C# how to convert data types inside a conditional

Hi i make a c# little program what request to the user 2 numbers and return a value but in case what the user input a double number, the program can will solve the problem with a if else statement buit i dont know how to do.

this is the code.

using System;

namespace c_
{
class suma
{
    static void Main(string[] args)
    {
        int N1;
        int N2;
        int suma;
        Console.WriteLine ("Digite el numero");
        N1 = int.Parse(Console.ReadLine());
        Console.WriteLine ("Digite el otro numero");
        N2 = int.Parse(Console.ReadLine());
        suma = N1 + N2;
        Console.WriteLine ("Total " + suma); 
    }
}
}

Aucun commentaire:

Enregistrer un commentaire