# C# 自定義60進位 ## 自定義轉60進位 ```c# class Base60Help { /// <summary> /// 進位 /// </summary> static int _Base = 60; /// <summary> /// N進位,最大支持60 /// </summary> /// <param name="input"></param> /// <returns></returns> public static string IntToBaseN(int n,long input) { if(n > _Base) { throw new NotImplementedException(); } StringBuilder sb = new StringBuilder(); while (input >= 1) { int index = Convert.ToInt16(input % n); char code = Base60Code[index]; sb.Insert(0, code); input = input / n; } return sb.ToString(); } public static string IntToBase60(long input) { StringBuilder sb = new StringBuilder(); while (input >= 1) { int index = Convert.ToInt16(input % _Base); char code = Base60Code[index]; sb.Insert(0, code); input = input / _Base; } return sb.ToString(); } public static Dictionary<int, char> Base60Code = new Dictionary<int, char>() { {0,'0'},{1,'1'},{2,'2'},{3,'3'},{4,'4'},{5,'5'},{6,'6'},{7,'7'},{8,'8'},{9,'9'}, {10,'a'},{11,'b'},{12,'c'},{13,'d'},{14,'e'},{15,'f'},{16,'g'},{17,'h'},{18,'i'},{19,'j'}, {20,'k'},{21,'m'},{22,'n'},{23,'o'},{24,'p'},{25,'q'},{26,'r'},{27,'s'},{28,'t'},{29,'u'}, {30,'v'},{31,'w'},{32,'x'},{33,'y'},{34,'z'},{35,'A'},{36,'B'},{37,'C'},{38,'D'},{39,'E'}, {40,'F'},{41,'G'},{42,'H'},{43,'I'},{44,'J'},{45,'K'},{46,'L'},{47,'M'},{48,'N'},{49,'P'}, {50,'Q'},{51,'R'},{52,'S'},{53,'T'},{54,'U'},{55,'V'},{56,'W'},{57,'X'},{58,'Y'},{59,'Z'} }; } ``` ###### tags: `C#`