What does “is { }” mean?

That’s just the empty property pattern in C# 8, meaning the value not null. It matches any value type or reference type. As Panagiotis Kanavos notes in the comments, this is equivalent to the good old value is object check which has been in C# for a long time.

Generally if you were to specify a property, then it would match or not. This esoteric example illustrates that:

if (value is { Length: 2 })
{
   // matches any object that isn't `null` and has a property set to a length of 2
}

The property patterns work best and are most clear when comparing with other patterns in cases such as switch expressions.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)