如何将long转换为字节和字符串 [英] how to i convert long to byte and string

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

问题描述

实际上我的代码在vb6



代码是: - strCardNo = CStr(ByteToLong(byteBuffer(0)))

这里我的字节数组值是byteBuffer(0)= 232



然后我得到了strCardNo = 1946184168





但是在vb.net中怎样才能得到????????





请告诉我的任何解决方案

actually my code in vb6

the code is:- strCardNo = CStr(ByteToLong(byteBuffer(0)))
here my byte array value is byteBuffer(0)=232

then i got strCardNo=1946184168


But in vb.net how can i get????????


please tell me any solution

推荐答案

您显示的代码将字节流转换为Long值,然后将其转换为s atring - 第一个字节的值只有一个转换后的那些:

向后工作:

The code you show converts a stream of bytes to a Long value, then converts that to s atring - the value of the first byte is only one of those converted:
Working backwards:
   1946184168 Decimal
==   740069E8 Hex



和0xE8 == 232因此它被转换为一个小端数,这很好。

所以:


And 0xE8 == 232 so it is converted as a little endian number, which is fine.
So:

Dim byteBuffer As Byte() = New Byte() {&He8, &H69, &H0, &H74, &H0, &H0, _
    &H0, &H0, &H0}
Dim sCardNo As String = BitConverter.ToInt64(byteBuffer, 0).ToString()


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

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