-
-
Save richlander/d76b1354a34967d44bd83083e7af7c51 to your computer and use it in GitHub Desktop.
Should rich go to the doctor
This file contains 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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net5.0</TargetFramework> | |
<Nullable>enable</Nullable> | |
</PropertyGroup> | |
</Project> |
This file contains 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; | |
using static System.Console; | |
Person p = new ("rich", 98); | |
var maybeIll = p switch | |
{ | |
{temperature: <97 } => true, | |
{temperature: >99} => true, | |
{Name: "rich", temperature: var temp} when temp switch | |
{ | |
>97 and <99 => true, | |
_ => false | |
} => true, | |
{temperature: >97 and <99} => false, | |
_ => false | |
}; | |
WriteLine($"{p.Name} should go to the doctor: {maybeIll}"); | |
public record Person(string Name, int temperature); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment