Closed rmantel23 closed 2 months ago
Thanks! I have added an improvement item for this here: https://github.com/markjprice/cs12dotnet8/blob/main/docs/errata/improvements.md#page-236---understanding-members
Thanks again Mark!
Maybe another idea. When reading this section, one could wonder why .NET wouldn't use a constant instead of a read-only field for something like UnixEpoch, since it is obviously a fixed value. I assume the answer is that only the C# built-in types may be declared as const. It might be helpful to add this where you explain the constant.
Constants have to be literal values. Although UnixEpoch
is, as you say, a "fixed value", it cannot be expressed as a literal value. I explain this in the detailed section about constants but I agree it might be useful to also briefly mention it earlier in the introductory section. I've updated the improvement item.
Maybe DateTime.UnixEpoch is not the best example for a Read-only field, because working through the chapter the reader would have just changed the TargetFramework to netstandard2.0, and UnixEpoch is not available until 2.1.