The exact warning I get is
Possible null reference argument for parameter 's' in 'double double.Parse(string s)
try
{
// this is the line where it shows the warning as `input` can be null:
double grade = double.Parse(input);
book.AddGrade(grade);
}
catch (ArgumentException ex)
{
System.Console.WriteLine(ex.Message);
}
Isn't the ArgumentNullException
that the parse function can throw comes under the ArgumentException
and thus should be handled?
Also I know TryParse
can also be used but as a complete beginner I'd like to know what I'm doing wrong.