字符串到字节数组值 [英] String to byte array value

查看:104
本文介绍了字符串到字节数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个数据库字段varbinary,我在c#中检索并存储在列表中。单击按钮时,我传递一个authnum值并将值存储在val中。



 var authval =来自authlt in lstarray 
其中authlt.AuthNum == authnum
选择authlt.authLetter;







i尝试打开pdf通过将authval提供给二进制编写器,以便在其中显示pdf的新窗口。但它不起作用。它要求我给出一个字节数组,我无法从字符串值中获取。



是否有办法将所有字符串字符串char复制到字节数组???

从字符串中显示pdf的任何其他方式?







任何帮助表示赞赏。

解决方案

尝试:

  byte  [] array = Encoding.UTF8.GetBytes(  Hello world!); 


hi,

I have a database field varbinary which I am retrieving in c# and storing in a list. on button click I am passing a authnum value and storing the value in val.

var authval = from authlt in lstarray
                          where authlt.AuthNum == authnum
                          select authlt.authLetter;




i tried opening a pdf by giving the authval to binary writer so that a new window in which pdf will appear. but its not working. it is asking me to give a byte array which i am unable to get from the string value.

is there a way to copy all the string char by char into byte array???
any other way to display pdf from the string?



any help is appreciated.

解决方案

Try:

byte[] array = Encoding.UTF8.GetBytes("Hello world!");


这篇关于字符串到字节数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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