namespace YBEE.EQM.Core; public static class ConvertUtil { public static string ConvertToChinese(int num) { if (num == 0) { return "零"; } string[] units = new string[] { "", "十", "百", "千", "万", "亿", "十亿", "百亿", "千亿", "兆" }; string[] digits = new string[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; bool isNegative = false; if (num < 0) { isNegative = true; num *= -1; } string result = ""; while (num > 0) { int digit = num % 10; if (!isZeroDigit(digit)) { result = digits[digit] + units[result.Length / 4] + result; } num /= 10; } if (isNegative) { result += "负"; } return result; bool isZeroDigit(int digit) { return digit == 0 || digit == 1 && string.IsNullOrEmpty(digits[digit]); } } }