Sql binary to c# - How to get SQL binary equivalent of binary in c#

后端 未结 2 629
野趣味
野趣味 2021-01-24 10:50

It might seem a dumb question to you guys. I have one SQL table with one binary column. It has some data in binary format.

e.g. 0x9A8B9D9A002020202020202020202020<

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-24 11:35

    public static byte[] ConvertToBinary(string str)
    {
        System.Text.ASCIIEncoding  encoding = new System.Text.ASCIIEncoding();
        return encoding.GetBytes(str);
    }
    

    or

    Convert.ToByte(string);
    

提交回复
热议问题