mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2025-12-06 05:32:03 +01:00
24 lines
451 B
C#
24 lines
451 B
C#
using System.Text.Json.Serialization; // [JsonInclude]
|
|
|
|
public class Book
|
|
{
|
|
// constructor to set non-nullable property
|
|
public Book(string title)
|
|
{
|
|
Title = title;
|
|
}
|
|
|
|
// properties
|
|
public string Title { get; set; }
|
|
public string? Author { get; set; }
|
|
|
|
// fields
|
|
[JsonInclude] // include this field
|
|
public DateTime PublishDate;
|
|
|
|
[JsonInclude] // include this field
|
|
public DateTimeOffset Created;
|
|
|
|
public ushort Pages;
|
|
}
|