* Implement the Pars method on type KeyCode, such that parsing an instance from the string
* generated with ToString() gives you back an identical instance.
public class ParsingRoundTripProgram
public record KeyCode(Prefix Prefix, uint Number, bool Open)
public override string ToString()
var openPart = this.Open ? "Y" : "N";
return $"{this.Prefix}-{this.Number}-{openPart}";
public static KeyCode Parse(string _)
private static void TestCase(KeyCode input)
Console.WriteLine($"Expected: {input}");
Console.WriteLine($"Actual: {KeyCode.Parse(input.ToString())}");
public static void Main()
TestCase(new KeyCode(Prefix.Alpha, 75243, true));
TestCase(new KeyCode(Prefix.Beta, uint.MaxValue, true));
TestCase(new KeyCode(Prefix.Alpha, 75243, false));
TestCase(new KeyCode(Prefix.Beta, 0, false));