473,405 Members | 2,338 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,405 software developers and data experts.

bytes to Integer

Hi All ,
I have converted a Integer to Byte and Written in to the file. After
that i read the file byte by byte then I want to Convert th Bytes to Integer
.. If any method is available to convert Bytes to Integer pls Let me Know.

Regards,
Govind.
Nov 15 '05 #1
3 15895
Govind <go******@interworldgroup.com> wrote:
I have converted a Integer to Byte and Written in to the file. After
that i read the file byte by byte then I want to Convert th Bytes to Integer
. If any method is available to convert Bytes to Integer pls Let me Know.


Look at BitConverter.ToInt32.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2

"Govind" <go******@interworldgroup.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All ,
I have converted a Integer to Byte and Written in to the file. After that i read the file byte by byte then I want to Convert th Bytes to Integer . If any method is available to convert Bytes to Integer pls Let me Know.


Hello,
Byte to integer conversion can be implicit. In other words, you don't need
to write special code.

byte b = Convert.ToByte("5", 10);
//Change it to an integer.
int i = b;
Console.WriteLine(i); // prints 5

You can look at the convert class, which is what I used to put the string
"5" into a byte, but you don't need it to convert a byte to an integer.

But maybe that's not what you need. Maybe you should look up serialization
in the help files. You don't have to convert stuff byte by byte yourself to
write it to a binary file.

HTH
Eric
Nov 15 '05 #3
"Eric Eggermann" <<none>> <"Eric Eggermann" <<none>>> wrote:
Byte to integer conversion can be implicit. In other words, you don't need
to write special code.


Yes he does. Reread the original post - he's not trying to convert a
*single* byte into an integer, but an array of bytes (presumably 4)
into an integer. Fortunately, BitConverter.ToInt32 has this covered.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #4

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

Similar topics

27
by: Daniel Lidström | last post by:
Hello! I want to work with individual bytes of integers. I know that ints are 32-bit and will always be. Sometimes I want to work with the entire 32-bits, and other times I want to modify just...
25
by: TK | last post by:
I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual...
8
by: ranjeet.gupta | last post by:
Dear All I am not able o understand the exact number of bytes allocation done by the two fucntion given below, It is said that the fuction Condition_String1 allocates the 240 bytes while...
1
by: Govind | last post by:
Hi All , I have converted a Integer to Byte and Written in to the file. After that i read the file byte by byte then I want to Convert th Bytes to Integer .. If any method is available to convert...
1
by: spamacon | last post by:
Hello, I have a strange situation using .Net FW 1.1. I want to use Marshal.PtrToStructure to fill the structure below. The first 3 fields get filled correctly: ulStruct describes how big the...
4
by: penzer | last post by:
how to exchange 1234(number) -bytes sequence in the C#?
33
by: Hahnemann | last post by:
Does anybody know the answer to the following? An unsigned short is 2 bytes long. Why is the following file created as 4 bytes instead of 2? file = fopen("data.bin", "wb"); if (file != NULL)...
8
by: sexauthor | last post by:
I'm converting a VB6 application over that called a 3rd party DLL with specific data structures. The VB6 code defined custom types for those data structures (ie: one with the specific data types,...
4
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.