473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

convert Int32 to array of bytes (2)

Jan
How can I convert Int32 (4 bytes long) value to array of
bytes?
I need only 4 bytes in result.

example: long value 55695542 -->

arr(0) == &HB6
arr(1) == &HD8
arr(2) == &H51
arr(3) == &H03
Thank you

Nov 19 '05 #1
3 9072
"Jan" <js***@nemtru.cz> schrieb
How can I convert Int32 (4 bytes long) value to array of
bytes?
I need only 4 bytes in result.

example: long value 55695542 -->

arr(0) == &HB6
arr(1) == &HD8
arr(2) == &H51
arr(3) == &H03


Dim arr as byte()
arr = BitConverter.GetBytes(MyInt)
--
Armin

Nov 19 '05 #2
jan

Thank you.

-----Original Message-----
"Jan" <js***@nemtru.cz> schrieb
How can I convert Int32 (4 bytes long) value to array of bytes?
I need only 4 bytes in result.

example: long value 55695542 -->

arr(0) == &HB6
arr(1) == &HD8
arr(2) == &H51
arr(3) == &H03


Dim arr as byte()
arr = BitConverter.GetBytes(MyInt)
--
Armin

.

Nov 19 '05 #3
Hello,

I have the same problem. How can I convert array of Int32 into Byte array?

---------------------------

Int32 i32Array = new Int32[3];

// ... I fill my array here ...

Byte byteArray[] = new Byte[ 3 * sizeof(System::Int32) ];

byteArray = ...???...(i32Array); //How to convert Int32 array into Byte array?
Jun 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: phancey | last post by:
I am trying to invoke a web service method dynamically. I have created a generic function that takes a method name, string of parameters and calls the web method using System.Reflection: ...
19
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
4
by: Ping | last post by:
Hi, All, We can use BitConverter.ToString(byte) to a string, but how to get the byte from a string like "AD-A6-0D-1F"?
14
by: Charles Law | last post by:
I thought this had come up before, but I now cannot find it. I have a byte array, such as Dim a() As Byte = {1, 2, 3, 4} I want to convert this to an Int32 = 01020304 (hex). If I use...
4
by: Sam | last post by:
Hi, I'm trying to convert a string to a binary format (byte) I've looked at BitConverter class, but I can't figure out how to use it for a Strin. Does anyone know ? Thx
6
by: moondaddy | last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a string, and then from a string back to a byte array. for example Private mByte() as New Byte(4){11,22,33,44} Now how...
14
by: Me | last post by:
Hi all I am getting a really bizzare error on when I convert a string into a datetime: The code is : DateTime dt1 = Convert.ToDateTime("10 Sep 2005"); Console.WriteLine(dt1.Year);
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
7
by: mehafi | last post by:
hi, I need to write a few integer numbers to file. A method write from FileStream writes an array of bytes. So how to conwert my integers to byte array? I've tried Convert class, but it hasn't...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.