如何将字符串转换为sbyte数组. [英] How to convert string to sbyte array.

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

问题描述

将字符串转换为sbyte时出现错误

对于字节保留,我使用了

I got error when i convert string to sbyte

For byte attay i used

byte[] abyte1 = new byte[4];
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
abyte1 = encoding.GetBytes(s1);


并且它的工作正常,没有错误.

但是当我将代码字节数组更改为sbyte数组时


and its work fine with no error.

but when i change code byte array to sbyte array

sbyte[] abyte1 = new sbyte[4];


则以上代码不起作用,并导致字符串到sbyte的转换错误.
有没有用于编码的system.tect类?
在我的代码中,我仅使用sbyte []数组,而不使用byte []数组.
请帮我这个问题,给我适当的答案.....

问候,
ravi


then above code is not work and got string to sbyte conversion error.
Is there any system.tect class for the encoding??
In my code i am only use sbyte[] array not byte[] array.
please help me for this giving me proper answer.....

regards,
ravi

推荐答案

首先转换String to Byte.然后转换Byte to SByte.
First convert the String to Byte. Then convert Byte to SByte.
byte[] abyte1 = new byte[4];
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
abyte1 = encoding.GetBytes(s1);

sbyte[] sbytes = Array.ConvertAll(abyte1, q => Convert.ToSByte(q));


通过以下链接进行搜索,这可能对您有帮助

此处 [
go through this below link this may helps you

Here[^]


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

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