sql和C#10进制转化62进制
1.SqlServer 10进制转换成62进制,写成函数方法
--@num 要转换的10进制 --@len 转换后保留支付长度 CREATE function [dbo].[intto62](@num bigint) returns varchar(16) begin declare @result varchar(100) set @result='' while @num>0 begin select @result=substring('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHLJKLMNOPQRSTUVWXYZ',@num%62+1,1)+@result,@num=@num/62 end return @result end
2.C# 10进制转换成62进制
private static char[] charSet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(); public static string To62(long number) { var str = string.Empty; var num = number; while (num > 0) { long val = num % 62; str = charSet[val] + str; num = num / 2; } return str; }