c# string.format input string was not in a correct format code example
Example: input string was not in a correct format. c#
//Trying to incorrectly convert a to a type when the string
// can not be converted. "5a00" is not a number
//use TryParse. Type.TryParse as in Int32.TryParse
//or Double.TryParse or decimal.TryParse ...
string response = string.Empty;
int someNumber = 0;
string number2Convert = "5a00";
var success = Int32.TryParse(number2Convert, out someNumber);
if (!success) response = $"Incorrect number format - '{number2Convert}'";
else response = $"The number is {someNumber}";
Console.WriteLine(response);