// Directions: Code Practice 5-2
// 1) Run the following code to see the error.
// 2) Add a try catch structure with an Exception ex in the parentheses to keep the application from crashing.
// 3) If an error occurs, the console should say the the following : "Error: Input string was not in a correct format.". The message should come from the ex.Message object.
// 4) Do not change lines 13 through 16.
// 5) Submit your dotnetfiddle link in Blackboard.
using System;
public class Program
{
public static void Main()
float fltHP = 0;
string strHP = "";
try
fltHP = float.Parse(strHP);
}
catch (Exception ex)
Console.WriteLine("Error: " + ex.Message);
Console.WriteLine("Value: " + fltHP);