Practice mode C#

What does the property pattern s is { Length: > 3 } test in C#?

Correct answer B. That s is not null and its Length property is greater than 3

Explanation

A property pattern checks that the input is non-null and that its named members match nested patterns. Here it requires s to be non-null and s.Length to satisfy the relational pattern > 3, so "hello" matches and "hi" or null do not. Property patterns can be nested to inspect deep object graphs in switch expressions without casts.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.