public class ReaderLayerResponseEventArgs {
public readonly byte[] id;
public readonly byte[] data;
public readonly TagType type;
public readonly string source;
public readonly int readCount; public ReaderLayerResponseEventArgs(byte[] id, byte[] data, TagType type, string source, int readCount) {
this.id = id;
this.data = data;
this.type = type;
this.source = source;
this.readCount = readCount;
}这段是MS 提供的,第一个参数,是byte 类型的,我要给这个参数传的是字节吧如: byte[] aa ={ 0x41,0x42,0x43,0x44};
有这样个数组,是我们设备传出来的数据
而直接把个个数组,传下去后,显示的是 41 42 43 44 这个而应该是显示的是 A B C D 所以问该如何转成 字节数组放里放 A B C D 或是有什么其他的 方法?
public readonly byte[] id;
public readonly byte[] data;
public readonly TagType type;
public readonly string source;
public readonly int readCount; public ReaderLayerResponseEventArgs(byte[] id, byte[] data, TagType type, string source, int readCount) {
this.id = id;
this.data = data;
this.type = type;
this.source = source;
this.readCount = readCount;
}这段是MS 提供的,第一个参数,是byte 类型的,我要给这个参数传的是字节吧如: byte[] aa ={ 0x41,0x42,0x43,0x44};
有这样个数组,是我们设备传出来的数据
而直接把个个数组,传下去后,显示的是 41 42 43 44 这个而应该是显示的是 A B C D 所以问该如何转成 字节数组放里放 A B C D 或是有什么其他的 方法?
char a=(char)aa[0];
byte[] bb;
byte [] aa= {0x41,0x42,0x43,0x44};
ASCIIEncoding s = new ASCIIEncoding();
st = s.GetString(aa);
// bb=st.ToCharArray();我这样试了下, ST =“ABCD ”
没错但 // bb=st.ToCharArray();
报错如下:
Error 2 Cannot implicitly convert type 'char[]' to 'byte[]'
字符都不会大于 F的 即不会出现 F 以后的字母是否可以 把 ABCD 做成
byte[0]=0xab
byte[0]=0xcd但不知道 这样 byte [] aa= {0x41,0x42,0x43,0x44};
一个数组 怎么转成 byte [] CC= {0xAB,0xCD}?;
你这里byte 存的是ASCII码,也就是说byte里不能存字母:)
再就是说,A B C D以ASCII编码形式的byte数组 就是41 42 43 44
你这里byte 存的是ASCII码,也就是说byte里不能存字母:)
再就是说,A B C D以ASCII编码形式的byte数组 就是41 42 43 44这个我知道 我做底层开发的,对上层处理不是很了解问题是地层抛出来的是 0x41 (假设现在为一个BYTE)
我现在用C#做的这个中间件 得到的也是 0x41而微软提供的接口函数的 参数也是byte 类型(无法改的),而直接给则显示为 41
所以我要处理
问题就在这里
比如这两句
但不知道 这样 byte [] aa= {0x41,0x42,0x43,0x44};
一个数组 怎么转成 byte [] CC= {0xAB,0xCD}?;
可以这么变,但这两个是完全不同的数组
byte [] aa= {0x41,0x42,0x43,0x44};
对应的 char[] cc={A,B,C,D};
最简单的 就是小橘子的 char a=(char)aa[0]; //做个循环对应转下就好
也可以char[] cc=System.Text.Encoding.ASCII.GetString(aa).ToCharArray();
你应该要的是这个 char数组吧