473,395 Members | 1,670 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,395 software developers and data experts.

Accessing each byte of a char


Is there any method that allows me have access to the individual bytes that
compounds a char variable ?

Regards,


Nov 15 '05 #1
7 1384
http://msdn.microsoft.com/library/de...sreadtopic.asp
"Tim Conner" <ti*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

Is there any method that allows me have access to the individual bytes that compounds a char variable ?

Regards,

Nov 15 '05 #2
http://msdn.microsoft.com/library/de...sreadtopic.asp
"Tim Conner" <ti*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

Is there any method that allows me have access to the individual bytes that compounds a char variable ?

Regards,

Nov 15 '05 #3
Tim,
Is there any method that allows me have access to the individual bytes that
compounds a char variable ?


((byte)c) and ((byte)(c>>8))

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #4
Tim,
Is there any method that allows me have access to the individual bytes that
compounds a char variable ?


((byte)c) and ((byte)(c>>8))

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #5
Tim,
Have you tried the System.BitConverter.GetBytes method.

It returns a byte array given most built-in types.

Hope this helps
Jay

"Tim Conner" <ti*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

Is there any method that allows me have access to the individual bytes that compounds a char variable ?

Regards,

Nov 15 '05 #6
Tim,
Have you tried the System.BitConverter.GetBytes method.

It returns a byte array given most built-in types.

Hope this helps
Jay

"Tim Conner" <ti*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

Is there any method that allows me have access to the individual bytes that compounds a char variable ?

Regards,

Nov 15 '05 #7
characters in C# are unicode, which means they're 16 bits, rather than 8
bits.

You can access them with array syntax, or with foreach syntax. If you want
to pull out the numeric value, you can then cast to a short or ushort.
"Tim Conner" <ti*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

Is there any method that allows me have access to the individual bytes that compounds a char variable ?

Regards,

Nov 15 '05 #8

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

Similar topics

5
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or...
1
by: J. Campbell | last post by:
I have a feeling that I'm doing things all ass-backwards (again ;-), and would like some advice. What I want to do is: put some data to memory and then access that memory space as an array of...
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...
10
by: Christian Christmann | last post by:
Hi, I'm wondering if my small example is not "dangerous": #define SIZE 10 char global; char* globalPtr = global; int main()
14
by: rsood | last post by:
Hi I'm developing a program, and naturally I want it to be as portable as possible. I need to be able to access specific numbers of bytes in it, but as far as I know, there is no keyword in the...
16
by: quantumred | last post by:
Can I use pointer arithmetic on the members of a structure in the following way? Should I be worried about structure padding? This works in my debugger but I wonder if I'm bending some rule here. ...
5
by: pt | last post by:
Hi, i am wonderng what is faster according to accessing speed to read these data structure from the disk in c/c++ including alignment handling if we access it on little endian system 32 bits...
5
by: Andy | last post by:
I'm having trouble accessing an unmanaged long from a managed class in VC++.NET When I do, the contents of the variable seem to be mangled. If I access the same variable byte-by-byte, I get the...
16
by: s0suk3 | last post by:
This code #include <stdio.h> int main(void) { int hello = {'h', 'e', 'l', 'l', 'o'}; char *p = (void *) hello; for (size_t i = 0; i < sizeof(hello); ++i) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.