SQL二进制到C# - 如何获得在C#中的二进制的SQL二进制数 [英] Sql binary to c# - How to get SQL binary equivalent of binary in c#

查看:183
本文介绍了SQL二进制到C# - 如何获得在C#中的二进制的SQL二进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎一个愚蠢的问题给你们。我有一个二进制列中的一个SQL表。它在二进制格式的某些数据。

例如。 0x9A8B9D9A002020202020202020202020

这相当于英语再presentation是测试。

是否有可能这个字符串转换成等效二进制形式 C#

 字符串s =测试; // C#code送转换成它的等价的SQL二进制形式。


解决方案

 公共静态的byte [] ConvertToBinary(字符串str)
{
System.Text.ASCIIEncoding编码=新System.Text.ASCIIEncoding();
返回encoding.GetBytes(STR);
}
   要么Convert.ToByte(字符串);

希望这有助于和有一个好一个,呃德别忘了接受的答案,如果这有助于:)!麦片

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

It's equivalent english representation is "test".

Is it possible to convert this string into equivalent binary form in c# ?

string s = "test"; // C# code to convert s to it's equivalent SQL binary form.

解决方案

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

Convert.ToByte(string);

Hope this helps and have a nice one, d'uh don't forget to accept the answer if this helps :)! cheerios

这篇关于SQL二进制到C# - 如何获得在C#中的二进制的SQL二进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆