generate functionThu, 22 Dec 2022

write a function to receive a whole number and return true if the digits are in ascending order from right to left

public static bool IsAscending(int number) { string str = number.ToString(); int[] nums = str.Select(c => c - '0').ToArray(); for (int i = 0; i < nums.Length-1; i++) { if (nums[i] > nums[i + 1]) return false; } return true; }

Questions about programming?Chat with your personal AI assistant