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?
Record with static helper
using System;
var weight = 200;
WeightMeasurement measurement = new(DateTime.Now, weight)
{
Pounds = WeightMeasurement.GetPounds(weight)
};
Console.WriteLine(measurement);
public record WeightMeasurement(DateTime Date, double Kilograms)
{
public double Pounds {get; init;}
public static double GetPounds(double kilograms) => kilograms * 2.20462262;
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>Enable</Nullable>
</PropertyGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.