Is there a routine in c# that will transform a string
ie"Hello Mom" into a
Byte[] array. I have found
char[] cTmp = pString.ToCharA rray();
But I have not been able to figure out how to convert a char into a hex
value and place that value into the byte[].
Thanks for your help
Dan C
Nov 15 '05
11 30584
Dan C <MSN/da********@msn. com> wrote: This is almost what I need. Unfortunately instead of "Hello" as decimal 72, 101, 108, 108, 111 I need the values in hex. this would be 48, 65, 6C, 6C, 6F. I think that these values will still fit in the byte array.
Byte arrays aren't *in* decimal or hex particularly - they're just
numbers. There's no difference between (say) decimal 16 and hex 10. If
you need to *display* the hex values, then just change how you're
formatting each byte - it's nothing to do with what byte is being
formatted though.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks that was what I needed to know. One last thing is there a better way
to overlay MasterByte[11] to MasterByte[20] with a NewByte array of 10
items?
I currently am using a loop
int nOffset = current posisition in MasterByte array
for(int i = 0; i < newArray.GetUpp erBound(0); i++)
{
MasterByte [nOffset++] = NewByte[x];
}
Thanks again
Dan C
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Dan C <MSN/da********@msn. com> wrote: This is almost what I need. Unfortunately instead of "Hello" as decimal
72, 101, 108, 108, 111 I need the values in hex. this would be 48, 65, 6C,
6C, 6F. I think that these values will still fit in the byte array.
Byte arrays aren't *in* decimal or hex particularly - they're just numbers. There's no difference between (say) decimal 16 and hex 10. If you need to *display* the hex values, then just change how you're formatting each byte - it's nothing to do with what byte is being formatted though.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where a * occurs in
the string). This split function should allocate a 2D array of chars
and put the split results in different rows. The listing below shows
how I started to work on this. To keep the program simple and help
focus the program the...
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that the data converted from the byte array into a string
, is not what i expect.
example:
- the data returned from the socket is (byte array)
"Usuario Sin Atribuciones Para Esta Función"
|
by: David Bargna |
last post by:
Hi
I have a problem, I have a string which needs to be converted to a
byte array, then have the string representation of this array stored
in an AD attribute. This string attribute then has to be read and the
string representation of the byte array has to be converted back to
the original byte array and converted back to the original string -
confused yet?
in psuedo
|
by: rsine |
last post by:
I have developed a program that sends a command through the serial port
to our business system and then reads from the buffer looking for a
number. Everything worked great on my WinXP system, but when I tried
the program on the Win98 system it will be running on, I get the
following error:
Cast from string "2076719" to type 'Long' is not valid
I am not sure why I only get this error on the Win98 system or how to go
about correcting...
|
by: Bryan |
last post by:
Apologies if this is a noob question, but I've been struggling with this for quite a while...
I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string that is displayed in a text box. Once displayed, the text will be copied, transmitted and then pasted (all manually by humans) into a second utility where the string must then be reverse-engineered into the *original* byte array. The byte array will...
| |
by: moondaddy |
last post by:
I need to convert a byte array to a string and pass it as a parameter in a
URL and then convert it back to the original byte array. However, its
getting scrambled in the conversion. In short, here's the code:
======================================
Dim textConverter As New ASCIIEncoding
Dim sParam As String = "This is my cool param"
Dim bytParam() As Byte
'load the byte array here...
|
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 do I convert it to:
dim myStr as string = "11,22,33,44"
|
by: ThunderMusic |
last post by:
Hi,
I have to go from Byte() to String, do some processing then reconvert the
String to byte() but using ascii format, not unicode.
I currently use a stream to write the char() (BinaryWriter.Write) from the
string (String.ToCharArray), then use Stream.ToArray to convert everything
to byte(). It works most of the time, but it happens that an error tells me
something like "Additional information: Caractère de substitution faible
trouvé...
|
by: da1978 |
last post by:
Hi experts,
I need to convert a string or a Byte array to a string byte array.
Its relatively easy to convert a string to an char array or a byte array but not a
STRING byte array. i.e.
Dim Array() As Char
Dim strwork As String = "76A3kj9d6"
Array = strwork.ToCharArray
OR
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |