📄 hextoten.cs
字号:
using System;
namespace WindowsApplication.HexToTen
{
/// <summary>
/// HexToTen 的摘要说明。
/// </summary>
public class HexToTen
{
public HexToTen()
{
}
public static string Hex2Ten(string hex)
{
int ten = 0;
for (int i=0,j=hex.Length-1 ; i<hex.Length ; i++)
{
ten += HexChar2Value(hex.Substring(i,1)) * ((int)Math.Pow(16,j));
j--;
}
return ten.ToString();
}
public static int HexChar2Value(string hexChar)
{
switch (hexChar)
{
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
return Convert.ToInt32(hexChar);
case "a":
case "A":
return 10;
case "b":
case "B":
return 11;
case "c":
case "C":
return 12;
case "d":
case "D":
return 13;
case "e":
case "E":
return 14;
case "f":
case "F":
return 15;
default:
return 0;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -