private static IResult <string, int> GetChoice(FeatureMap featureMap) { var choice = Console.ReadLine(); return(!Int32.TryParse(choice, out int x) ? Result.Failure <string, int>("Couldn't parse " + choice + " as an integer") : featureMap.DoesFeatureExist(x) ? Result.Success <string, int>(x) : Result.Failure <string, int>("Don't know the feature for choice #" + x)); }