C# Debugging help // Handles a Format Exception if user does not enter a number using System;
Fantastic news! We've Found the answer you've been seeking!
Question:
C# Debugging help
// Handles a Format Exception if user does not enter a number
using System;
using static System.Console;
class DebugEleven01
{
static void Main()
{
double salary;
string salVal;
bool isValidSalary;
while(!isValidSalary)
{
try
Write("Enter an employee's salary ");
salVal = ReadLine();
salary = Convert.ToDouble(salVal);
isValidSalary = true;
catch(Formatexception fe)
{
WriteLine("You must enter a number for the salary");
}
}
WriteLine("The salary {0} is valid", salary.ToString("C2"));
}
}
Related Book For
Posted Date: