IDE has suggested the following Syntax change
while ((line = sr.ReadLine()) != null)
while (sr.ReadLine() is { } line)
{
output += line + "\n";
}
Must be a relatively new C# feature, but I am unable to find documentation of this "syntactic sugar" anywhere, involving the { }
. I understand what it does but is there any doc anywhere?
I found this but does not seem to be appearing https://learn.microsoft.com/en-US/dotnet/csharp/language-reference/operators/patterns#list-patterns