Unusual if statement in MaterialDesign codebase - would appreciate help #3339
-
Hi, when browsing the codebase, I came across the following if statement: I have not kept up with changes in the C# language, would appreciate if you could explain how the braces and the variable work. And most importantly, what is the official name of this construct in C# standard? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The name for this is "property pattern matching". It is both performing a null check, but if the value of You can read more about it here: https://essentialcsharp.com/pattern-matching#property-patterns-c-8-0-10-0 |
Beta Was this translation helpful? Give feedback.
The name for this is "property pattern matching". It is both performing a null check, but if the value of
HintProxy
is not null, it will assign the non-null value tohintProxy
and the expression returns true.You can read more about it here: https://essentialcsharp.com/pattern-matching#property-patterns-c-8-0-10-0