C# Feature - Out variables
Overview
Section titled βOverviewβOut variables allow inline declaration of out arguments, reducing the need for separate variable setup lines.
Introduced In
Section titled βIntroduced InβC# 7.0 (2017)
int number;if (int.TryParse(text, out number)){ Console.WriteLine(number);}if (int.TryParse(text, out int number)){ Console.WriteLine(number);}Gotchas & Best Practices
Section titled βGotchas & Best Practicesβ- Use discards when the parsed value is not needed.
- Keep the variable scope small by declaring it inline.