Skip to content

Instantly share code, notes, and snippets.

@richlander

richlander/Program.cs Secret

Last active Oct 13, 2020
Embed
What would you like to do?
Should rich go to the doctor
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
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