not null
instead of an empty recursive pattern when checking for nullness CS-R1120One way to check for nullness using pattern matching is to use the empty recursive pattern syntax {}
. However, consider using not null
instead as it is more readable and easier to comprehend as it accurately conveys what it achieves.
if (obj is C
{
field: { }
})
{
// ...
}
if (obj is C
{
field: not null
})
{
// ...
}