Tips #1 - Record types and equality checks
Péter Magyar
Péter Magyar
In C# we have a really neat function to check record types and also to check the eqaulity of them. But let's have a look what is a record type first.
It is available from C# 10 and it adds a record struct to be able to define records as value types.
Here you can see a small exmaple of it.
var itsMePeter = new Person("Peter","Magyar");
var itsStillMePeter = new Person("Peter","Magyar");
//True
Console.WriteLine(itsMePeter.Equals(itsStillMePeter));
//True
Console.WriteLine(itsMePeter == itsStillMePeter);
public record Person(
string FirstName,
string LastName
);