7.14 now matches book (constructor warning disabled)
MODIFY
src/Chapter07/Listing07.14.SpecifyingWhichBaseConstructorToInvoke.cs
src/Chapter07/Listing07.14.SpecifyingWhichBaseConstructorToInvoke.cs
@@ -15,10 +15,13 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter07.Listing07_14
}
public class Contact : PdaItem
{
- public Contact(string name)
- : base(name)
+ // Disable warning since FirstName&LastName set via Name property
+ #pragma warning disable CS8618 // Non-nullable field is uninitialized.
+ public Contact(string name) :
+ base(name)
{
}
+ #pragma warning restore CS8618
public override string Name
{
@@ -37,9 +40,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter07.Listing07_14
}
[NotNull] [DisallowNull]
- public string? FirstName { get; set; }
+ public string FirstName { get; set; }
[NotNull] [DisallowNull]
- public string? LastName { get; set; }
+ public string LastName { get; set; }
// ...
}

7.14 now matches book (constructor warning disabled)