I have this piece of code :
//EDIT
DateTime finalDate;
Dictionary<string, string> a = new Dictionary<string, string>() { { "a", "2016-04-14T11:56:56.0319859+02:00" } };
string dateStr;
DateTime date;
if (json.TryGetValue("a", out dateStr) && DateTime.TryParse(dateStr, out date))
{
finalDate = date;
}
But I have the error inside the if "Use of unassigned local variable 'myDate'". If I'm not wrong, if this part is executed myDate has to be assigned by TryParse (technically even if the condition was false it should also be assigned), if I put the TryParse inside the if it works. Is there a way to tell the compiler that it is ok ?