TryParse with out var param

A new feature in C# 6.0 allows to declare variable inside TryParse
method.

Declaration expressions was cut from C# 6.0 and wasn’t shipped in the final release. You currently can’t do that. There is a proposal for it on GitHub for C# 7 (also see this for future reference).

Update (07/03/2017)

With the official release of C#7, the following code compiles:

string s = "42";

if (int.TryParse(s, out var result))
{
     Console.WriteLine(result);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)