[csharp]
private static Byte[] ConvertFrom(string strTemp)
{
try
{
if (Convert.ToBoolean(strTemp.Length & 1))//数字的二进制码最后1位是1则为奇数
{
strTemp = "0" + strTemp;//数位为奇数时前面补0
}
Byte[] aryTemp = new Byte[strTemp.Length / 2];
for (int i = 0; i < (strTemp.Length / 2); i++)
{
aryTemp[i] = (Byte)(((strTemp[i * 2] - ‘0‘) << 4) | (strTemp[i * 2 + 1] - ‘0‘));
}
return aryTemp;//高位在前
}
catch
{ return null; }
}
/// <summary>
/// BCD码转换16进制(压缩BCD)
/// </summary>
/// <param name="strTemp"></param>
/// <returns></returns>
public static Byte[] ConvertFrom(string strTemp, int IntLen)
{
try
{
Byte[] Temp = ConvertFrom(strTemp.Trim());
Byte[] return_Byte = new Byte[IntLen];
if (IntLen != 0)
{
if (Temp.Length < IntLen)
{
for (int i = 0; i < IntLen - Temp.Length; i++)
{