I wrote code like this
using (var reader = new StreamReader("SomeFilePath"))
{
while(reader.ReadLine() is string currentLine)
{}
}
Then My IDE Rider suggested me below with comment "Use null check pattern"
using (var reader = new StreamReader("SomeFilePath"))
{
while(reader.ReadLine() is {} currentLine)
{}
}
I thought that would make syntax error, but it didn't
That Line Of Code does her job nicely.
So my question is what is {} in while(reader.ReadLine is {} currentLine)
maybe it's kind of Record Expression?
Also I could not figure out why {} currentLine is better than string currentLine
Thank you for your help