TOPIC

RunTime Error - Ajuda

pmorais11 asked 2 years ago

Galera, está dando uma exceção quando rodo o código. O que pode ser?

EXCEÇÃO

"Input string was not in a correct format." error.

CÓDIGO

using System; 

public class URI {

    public static void Main(string[] args) { 

        int codigoPeca01, numeroPeca01, codigoPeca02, numeroPeca02;
        decimal valorUniPeca01, valorUniPeca02;

        codigoPeca01 = Convert.ToInt32(Console.ReadLine());
        numeroPeca01 = Convert.ToInt32(Console.ReadLine());
        valorUniPeca01 = Convert.ToDecimal(Console.ReadLine());

        codigoPeca02 = Convert.ToInt32(Console.Read());
        numeroPeca02 = Convert.ToInt32(Console.Read());
        valorUniPeca02 = Convert.ToDecimal(Console.Read());

        decimal valorPecas01 = numeroPeca01 * valorUniPeca01;
        decimal valorPecas02 = numeroPeca02 * valorUniPeca02;
        decimal valorTotalPecas = valorPecas01 + valorPecas02;

        Console.WriteLine("VALOR A PAGAR: R$ " + valorTotalPecas);
    }
}

Remember not post solutions. Your post may be reviewed by our moderators.