mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-05 06:15:24 +00:00
Added item for page 244
This commit is contained in:
parent
8fe96c5f62
commit
ee316fde8a
3 changed files with 43 additions and 13 deletions
18
vscode/Chapter05/PacktLibraryModern/Records.cs
Normal file
18
vscode/Chapter05/PacktLibraryModern/Records.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
namespace Packt.Shared;
|
||||
|
||||
public class ImmutablePerson
|
||||
{
|
||||
public string? FirstName { get; init; }
|
||||
public string? LastName { get; init; }
|
||||
}
|
||||
|
||||
public record ImmutableVehicle
|
||||
{
|
||||
public int Wheels { get; init; }
|
||||
public string? Color { get; init; }
|
||||
public string? Brand { get; init; }
|
||||
}
|
||||
|
||||
// simpler way to define a record
|
||||
// auto-generates the properties, constructor, and deconstructor
|
||||
public record ImmutableAnimal(string Name, string Species);
|
||||
Loading…
Add table
Add a link
Reference in a new issue