コード例 #1
0
    public static int DescendingOrder(int inputNumber)
    {
        int output;

        // it was not explained in the task how to handle negative values so only choice I had was to throw an exception
        if (inputNumber < MinimalAllowedNumber)
        {
            throw new Exception($"Input number must be higher than or equal to { MinimalAllowedNumber }.");
        }

        var inputNumberAsCharArray = ConvertionHelper.IntToCharArray(inputNumber);

        SortingHelper.SortCharArrayDescending(inputNumberAsCharArray);
        output = ConvertionHelper.CharArrayToInt(inputNumberAsCharArray);

        return(output);
    }