tentohex.cs

来自「独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 」· CS 代码 · 共 67 行

CS
67
字号
using System;

namespace WindowsApplication.TenToHex
{
	/// <summary>
	/// TenToHex 的摘要说明。
	/// </summary>
	public class TenToHex
	{
		public TenToHex()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public static string Ten2Hex(string ten)
		{
			ulong tenValue = Convert.ToUInt64(ten);
			ulong divValue,resValue;
			string hex = "";
			do
			{
				divValue = (ulong)Math.Floor(tenValue/16);
				resValue = tenValue%16;
				hex = tenValue2Char(resValue) + hex;
				tenValue = divValue;
			}
			while (tenValue >= 16);
			if (tenValue != 0)
				hex = tenValue2Char(tenValue) + hex;
			return hex;
		}

		public static string tenValue2Char(ulong ten)
		{
			switch(ten)
			{
				case 0:
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:
				case 8:
				case 9:
					return ten.ToString();
				case 10:
					return "A";
				case 11:
					return "B";
				case 12:
					return "C";
				case 13:
					return "D";
				case 14:
					return "E";
				case 15:
					return "F";
				default:
					return "";
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?