一个将数字转成字母的方法

 1         private static string Num_to_letter(int value)
 2         {
 3             //此处判断输入的是否是正整数数字
 4             if (Regex.IsMatch(value.ToString(), "^\\d+$"))
 5             {
 6                 int remainder = value % 26;
 7                 //remainder = (remainder == 0) ? 26 : remainder;
 8                 int front = (value - remainder) / 26;
 9                 if (front == 0)
10                 {
11                     return Level[remainder];
12                 }
13                 else if (front < 26)
14                 {
15                     return Level[front - 1] + Level[remainder];
16                 }
17                 else
18                 {
19                     return Num_to_letter(front) + Level[remainder];
20                 }
21             }
22             else
23             {
24                 return string.Empty;
25             }
26 
27         }

 

相关文章:

  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-17
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-12-08
  • 2022-03-06
相关资源
相似解决方案