79662151

Date: 2025-06-11 14:26:14
Score: 1
Natty:
Report link

May I suggest a different naming?
It makes the code more readable to me

Given enums Alpha and Beta
Then I create the following class

public static class AlphaFrom
{
  public static Alpha Beta(Beta beta) => beta switch
  {
    Alpha.Item1 => Beta.I1,
    Alpha.Item2 => Beta.I2,
    Alpha.Item3 => Beta.I3,
    _ => throw new ArgumentException("")
  }
}

Because the code using it becomes easy to read

var beta = BetaFromWhatever();
var alpha = AlphaFrom.Beta(beta);
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Roger Wernersson