Out parameters has to be set, therefore if TryParse fails it will initialize the output to it's default before it returns, however you will and in the "else" loop... Meaning it failed...
Try running the code below, that will show you that TryParse actually overwrites the value, yet indicates that the parse fails...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ParseAndOutput("");
ParseAndOutput("1.0");
ParseAndOutput("ABC");
}
private static void ParseAndOutput(string input)
{
double value = -1;
if (double.TryParse(input, out value))
{
Console.WriteLine("Parse succeeded for '"+input+"', try parse changed to: " + value);
}
else
{
Console.WriteLine("Parse failed for '" + input + "', try parse changed to: " + value);
}
}
}
}
So both Parse and TryParse fails on string.Empty, they just report that failure differently which is the whole point of TryParse, it is never meant to throw an exception...