Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
out var with C# 7
// C# 6
string n = "42";
int result;
if (string.TryParse(n, out result)
{
Console.WriteLine($"Converting to a number was successful: {result}");
}
// C# 7
string n = "42";
if (string.TryParse(n, out var result)
{
Console.WriteLine($"Converting to a number was successful: {result}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment