从十进制(base-10)转换为字母数字(base-36) [英] convert from decimal(base-10) to alphanumeric(base-36)

查看:515
本文介绍了从十进制(base-10)转换为字母数字(base-36)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过控制台执行一个程序,将数字基数10转换为基数36,我尝试搜索并找到一个:  https://social.msdn.microsoft.com/Forums / vstudio / zh-CN / 5babf71f-4375-40aa-971a-21c1f0b9762b / convert-from-decimalbase10-to-alphanumericbase36?forum = csharpgeneral,

I need to do a program by console, for convert a number base 10 to base 36, I tried to search and I found that one: https://social.msdn.microsoft.com/Forums/vstudio/en-US/5babf71f-4375-40aa-971a-21c1f0b9762b/convert-from-decimalbase10-to-alphanumericbase36?forum=csharpgeneral,

但是这对我没有帮助,我需要复制它并粘贴它,因为我是C#的新手,我需要为我的老师提供程序,任何人都可以这样做并解释它吗? 

but this dosn't help me, I need to copy it and paste it, because I'm new in C# and I need the program for my teacher, anyone can do it and explain it? 

推荐答案

 private static string ToBase36(ulong value)
        {
            const string base36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var sb = new StringBuilder(13);
            do
            {
                sb.Insert(0, base36[(byte)(value % 36)]);
                value /= 36;
            } while (value != 0);
            return sb.ToString();
        }





这篇关于从十进制(base-10)转换为字母数字(base-36)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆