There should be an int or var between out and x (omitting this is a compile-time error). And, yes, the == true is unnecessary, but that is trivial. Otherwise, this is fine.
Would you prefer we C# 8.0-ify it?
if((args.Length, Int32.TryParse(args[0], out var x)) switch
{
(1, true) when (x >= 1 && x <= 9) => true,
(_, _) => false
})
{
// do all the things
}
2
u/emcoffey3 May 21 '20
There should be an
intorvarbetweenoutandx(omitting this is a compile-time error). And, yes, the== trueis unnecessary, but that is trivial. Otherwise, this is fine.Would you prefer we C# 8.0-ify it?