/// <summary>
/// 字符串轉換為BCD編碼
/// </summary>
/// <param name="strTemp">轉換字符串</param>
/// <returns>BCD編碼</returns>
private 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; }
}
