Skip to content

Instantly share code, notes, and snippets.

@aemloviji
Created December 7, 2022 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aemloviji/b97b53e28b968d468465ceb3976bede8 to your computer and use it in GitHub Desktop.
Save aemloviji/b97b53e28b968d468465ceb3976bede8 to your computer and use it in GitHub Desktop.
C# lowering record type
// create an instance of Device
var device1 = new Device("DELL", "f8078ddc-2d59-4902-9acd-8cd88649186d");
// copy device1 with some modification using with expression
// to achive nondestructive mutation
var device2 = device1 with { Identifier = "aea8be94-788a-4b01-a569-9f496904a49c" };
// Device record type definition
public record Device(string Manufacturer, string Identifier);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment