字符转成二进制StrToByte

public static byte[] StrToByte(string strValue)
{
    int length = strValue.Length;
    byte[] buffer = new byte[length / 2];
    if ((length % 2) == 0)
    {
        for (int i = 0; i < (length / 2); i++)
        {
            buffer[i] = Convert.ToByte(strValue.Substring(i * 2, 2), 0x10);
        }
    }
    return buffer;
}
posted @ 2011-06-07 09:41  94cool  阅读(275)  评论(0编辑  收藏  举报