I believe the correct way would be like
string strValue= "0.45";
if (string.IsNullOrEmpty(strValue))
{
Console.WriteLine("String is null or empty.");
return;
}
float floatValue;
if (!float.TryParse(strValue, out floatValue))
{
Console.WriteLine("Invalid number format.");
}
Ideally, you should have a Helper Class with helper functions like ConvertToFloat in which you embed the above logic to have a consistent output.