diff --git a/exercises/concept/tim-from-marketing/.docs/introduction.md b/exercises/concept/tim-from-marketing/.docs/introduction.md index e7aa8ef723..6e1ab9a62e 100644 --- a/exercises/concept/tim-from-marketing/.docs/introduction.md +++ b/exercises/concept/tim-from-marketing/.docs/introduction.md @@ -4,7 +4,7 @@ In C#, the `null` literal is used to denote the absence of a value. A _nullable_ type is a type that allows for `null` values. -Prior to C# 8.0, reference types were always nullable and value types were not. A value type can be made nullable though by appending it with a question mark (`?`). +Prior to C# 8.0, reference types were always nullable and value types were not. A value type can be made nullable by appending a question mark to it (`?`). ```csharp string nullableReferenceType = "hello"; @@ -17,7 +17,7 @@ int? nullableValueType = 5; // Define nullable value type nullableValueType = null; // Valid as type is nullable ``` -Accessing a member of a variable which value is `null` will compile fine, but result in a `NullReferenceException` being thrown at runtime: +Accessing a null variable's member does not cause a compile error, but results in a `NullReferenceException` being thrown at runtime: ```csharp string sentence = null; @@ -36,7 +36,7 @@ string? nullableReferenceType = "movie"; nullableReferenceType = null; // Valid as type is nullable ``` -To safely work with nullable values, one should check if they are `null` before working with them: +To safely work with nullable values, check if they are `null` before using them: ```csharp string NormalizedName(string? name) @@ -45,12 +45,10 @@ string NormalizedName(string? name) { return "UNKNOWN"; } - else - { - // Value is not null at this point, so no compile warning - // and no runtime NullReferenceException being thrown - return name.ToUpper(); - } + + // Value is not null at this point, so no compile warning + // and no runtime NullReferenceException being thrown + return name.ToUpper(); } NormalizedName(null); // => "UNKNOWN"