Skip to content

Commit 051bf43

Browse files
paneerBillWagner
authored andcommitted
use NullConditional and Null Coalescing ops to suggest No Answer (#1559)
1 parent 9c0f1c2 commit 051bf43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

csharp/NullableIntroduction/NullableIntroduction/SurveyResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class SurveyResponse
1414

1515
// <SnippetSurveyStatus>
1616
public bool AnsweredSurvey => surveyResponses != null;
17-
public string Answer(int index) => surveyResponses.GetValueOrDefault(index, "No answer")!;
17+
public string Answer(int index) => surveyResponses?.GetValueOrDefault(index) ?? "No answer";
1818
// </SnippetSurveyStatus>
1919

2020
public SurveyResponse(int id) => Id = id;

0 commit comments

Comments
 (0)