diff --git a/vs4win/Chapter05/PacktLibraryModern/Book.cs b/vs4win/Chapter05/PacktLibraryModern/Book.cs index cfbfa51..78c2ed2 100644 --- a/vs4win/Chapter05/PacktLibraryModern/Book.cs +++ b/vs4win/Chapter05/PacktLibraryModern/Book.cs @@ -7,7 +7,7 @@ public class Book public Book() { } // For use with initialization syntax. [SetsRequiredMembers] - public Book(string isbn, string title) + public Book(string? isbn, string? title) { Isbn = isbn; Title = title; diff --git a/vs4win/Chapter05/PeopleApp/Program.cs b/vs4win/Chapter05/PeopleApp/Program.cs index 8e9c6e2..37b75ae 100644 --- a/vs4win/Chapter05/PeopleApp/Program.cs +++ b/vs4win/Chapter05/PeopleApp/Program.cs @@ -169,10 +169,11 @@ Book book = new() }; */ Book book = new(isbn: "978-1803237800", - title: "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals"); - -book.Author = "Mark J. Price"; -book.PageCount = 821; + title: "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals") +{ + Author = "Mark J. Price", + PageCount = 821 +}; WriteLine("{0}: {1} written by {2} has {3:N0} pages.", book.Isbn, book.Title, book.Author, book.PageCount); diff --git a/vscode/Chapter05/PacktLibraryModern/Book.cs b/vscode/Chapter05/PacktLibraryModern/Book.cs index cfbfa51..78c2ed2 100644 --- a/vscode/Chapter05/PacktLibraryModern/Book.cs +++ b/vscode/Chapter05/PacktLibraryModern/Book.cs @@ -7,7 +7,7 @@ public class Book public Book() { } // For use with initialization syntax. [SetsRequiredMembers] - public Book(string isbn, string title) + public Book(string? isbn, string? title) { Isbn = isbn; Title = title; diff --git a/vscode/Chapter05/PeopleApp/Program.cs b/vscode/Chapter05/PeopleApp/Program.cs index 8e9c6e2..37b75ae 100644 --- a/vscode/Chapter05/PeopleApp/Program.cs +++ b/vscode/Chapter05/PeopleApp/Program.cs @@ -169,10 +169,11 @@ Book book = new() }; */ Book book = new(isbn: "978-1803237800", - title: "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals"); - -book.Author = "Mark J. Price"; -book.PageCount = 821; + title: "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals") +{ + Author = "Mark J. Price", + PageCount = 821 +}; WriteLine("{0}: {1} written by {2} has {3:N0} pages.", book.Isbn, book.Title, book.Author, book.PageCount);