Last active
June 6, 2021 06:47
-
-
Save rstropek/748161e42d7a0b840f1a86c03f2715ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
var p = new Person("Foo", "Bar", 42); | |
// The following line does not work because records are immutable | |
// p.LastName = "Baz"; | |
Console.WriteLine(p.FirstName); | |
var b = new Product("Bike", "Mountainbike", 499m); | |
Console.WriteLine(b.Name); | |
// Usual syntax, results in record classes (=reference types) | |
record Person(string FirstName, string LastName, int Age); | |
// New syntax "record class" | |
record class Product(string Category, string Name, decimal Price); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment