c#中的转换问题 [英] conversion problem in c#

查看:65
本文介绍了c#中的转换问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我已经完成了字节到字符串的转换..在我的系统中工作正常。 ..但像字符串到字节内部异常的鞋子错误...任何人都知道请告诉我..为什么它发生

我的代码行是

System.Text .UTF8Encoding encoding = new System.Text.UTF8Encoding();

string customerID1 = encoding.GetString((byte [])bytedata);



请告诉em谁知道答案

Hi all,


I have done conversion of byte to string ..it''s working fine in my system...but shoeing error like string to byte inner exception...can any one knows please tell me ..why it is happening
my code lines are
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
string customerID1 = encoding.GetString((byte[])bytedata);

please tell em anyone knows answer

推荐答案

取决于字节数组中的内容 - 如果是UTF8字符集之外的数据,则会出现错误。



首先检查你如何生成字节数组,然后反转操作! (很可能你没有开始使用UTF8数据,但我不知道它是什么,所以我不能确切地说你应该做什么)
Depends what is in the byte array - if it is data which is outside the UTF8 character set, you will get the error.

Check how you generated the byte array in the first place, and reverse the operation! (It is likely that you didn''t start with UTF8 data, but I don''t know what it is, so I can''t say exactly what you should be doing)


这篇关于c#中的转换问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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