6 个解决方案
#1
int,没有十六进制还是十进制一说。
string ss = "0x7F";
int a = int.Parse(ss.Substring(2), NumberStyles.HexNumber);
#2
您这里得到的是7F,我想得到0x7F.
#3
int 没有0x这一说,没有十进制还是十六进制这一说,只有格式化成字符串后才有这一说。
#4
可以肯定楼主不是学计算机的,计算机里面只有二进制,十进制、十六进制都是给人看的,必然是字符串
#5
可以肯定楼主不是学计算机的,计算机里面只有二进制,十进制、十六进制都是给人看的,必然是字符串
#6
很简单,自己写一个程序,批量修改你的代码文件就可以了
提交各进制转换的代码给你,自已发挥吧
/// <summary>
/// 36进制内的数值转10进制
/// </summary>
/// <param name="radixnum"></param>
/// <param name="radix"></param>
/// <returns></returns>
public int toN10(string radixnum, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
char[] _ary = radixnum.ToCharArray();
int _log = 1;
int sn = 0;
for (int i = _ary.Length - 1; i >= 0; i--)
{
sn = sn + _num.IndexOf(_ary[i]) * _log;
_log = _log * radix;
}
return sn;
}
/// <summary>
/// 10进制转36进制
/// </summary>
/// <param name="n10"></param>
/// <param name="radix"></param>
/// <returns></returns>
private string toN36(int n10, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
int sn = n10;
string _rul = string.Empty;
while (sn >= radix)
{
_rul = _num.Substring(sn % radix, 1) + _rul;
sn = sn / radix;
}
return _num.Substring(sn % radix, 1) + _rul;
}
提交各进制转换的代码给你,自已发挥吧
/// <summary>
/// 36进制内的数值转10进制
/// </summary>
/// <param name="radixnum"></param>
/// <param name="radix"></param>
/// <returns></returns>
public int toN10(string radixnum, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
char[] _ary = radixnum.ToCharArray();
int _log = 1;
int sn = 0;
for (int i = _ary.Length - 1; i >= 0; i--)
{
sn = sn + _num.IndexOf(_ary[i]) * _log;
_log = _log * radix;
}
return sn;
}
/// <summary>
/// 10进制转36进制
/// </summary>
/// <param name="n10"></param>
/// <param name="radix"></param>
/// <returns></returns>
private string toN36(int n10, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
int sn = n10;
string _rul = string.Empty;
while (sn >= radix)
{
_rul = _num.Substring(sn % radix, 1) + _rul;
sn = sn / radix;
}
return _num.Substring(sn % radix, 1) + _rul;
}
#1
int,没有十六进制还是十进制一说。
string ss = "0x7F";
int a = int.Parse(ss.Substring(2), NumberStyles.HexNumber);
#2
int,没有十六进制还是十进制一说。
string ss = "0x7F";
int a = int.Parse(ss.Substring(2), NumberStyles.HexNumber);
您这里得到的是7F,我想得到0x7F.
#3
int,没有十六进制还是十进制一说。
string ss = "0x7F";
int a = int.Parse(ss.Substring(2), NumberStyles.HexNumber);
您这里得到的是7F,我想得到0x7F.
int 没有0x这一说,没有十进制还是十六进制这一说,只有格式化成字符串后才有这一说。
#4
可以肯定楼主不是学计算机的,计算机里面只有二进制,十进制、十六进制都是给人看的,必然是字符串
#5
可以肯定楼主不是学计算机的,计算机里面只有二进制,十进制、十六进制都是给人看的,必然是字符串
#6
很简单,自己写一个程序,批量修改你的代码文件就可以了
提交各进制转换的代码给你,自已发挥吧
/// <summary>
/// 36进制内的数值转10进制
/// </summary>
/// <param name="radixnum"></param>
/// <param name="radix"></param>
/// <returns></returns>
public int toN10(string radixnum, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
char[] _ary = radixnum.ToCharArray();
int _log = 1;
int sn = 0;
for (int i = _ary.Length - 1; i >= 0; i--)
{
sn = sn + _num.IndexOf(_ary[i]) * _log;
_log = _log * radix;
}
return sn;
}
/// <summary>
/// 10进制转36进制
/// </summary>
/// <param name="n10"></param>
/// <param name="radix"></param>
/// <returns></returns>
private string toN36(int n10, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
int sn = n10;
string _rul = string.Empty;
while (sn >= radix)
{
_rul = _num.Substring(sn % radix, 1) + _rul;
sn = sn / radix;
}
return _num.Substring(sn % radix, 1) + _rul;
}
提交各进制转换的代码给你,自已发挥吧
/// <summary>
/// 36进制内的数值转10进制
/// </summary>
/// <param name="radixnum"></param>
/// <param name="radix"></param>
/// <returns></returns>
public int toN10(string radixnum, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
char[] _ary = radixnum.ToCharArray();
int _log = 1;
int sn = 0;
for (int i = _ary.Length - 1; i >= 0; i--)
{
sn = sn + _num.IndexOf(_ary[i]) * _log;
_log = _log * radix;
}
return sn;
}
/// <summary>
/// 10进制转36进制
/// </summary>
/// <param name="n10"></param>
/// <param name="radix"></param>
/// <returns></returns>
private string toN36(int n10, int radix)
{
string _num = "0123456789ABCDEFGHIJKLMNOPQRSTUVWSYZ";
int sn = n10;
string _rul = string.Empty;
while (sn >= radix)
{
_rul = _num.Substring(sn % radix, 1) + _rul;
sn = sn / radix;
}
return _num.Substring(sn % radix, 1) + _rul;
}