Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading Problem Pin
ACorbs23-Apr-05 17:06
ACorbs23-Apr-05 17:06 
Generalcalculate grade point average for 2 students Pin
keithbg22-Apr-05 16:21
keithbg22-Apr-05 16:21 
GeneralRe: calculate grade point average for 2 students Pin
Dave Kreskowiak22-Apr-05 17:23
mveDave Kreskowiak22-Apr-05 17:23 
GeneralRe: calculate grade point average for 2 students Pin
Christian Graus22-Apr-05 17:49
protectorChristian Graus22-Apr-05 17:49 
GeneralRe: calculate grade point average for 2 students Pin
leppie22-Apr-05 20:58
leppie22-Apr-05 20:58 
GeneralRe: calculate grade point average for 2 students Pin
S. Senthil Kumar22-Apr-05 22:31
S. Senthil Kumar22-Apr-05 22:31 
GeneralRe: calculate grade point average for 2 students Pin
Christian in a nice hotel in Singapore24-Apr-05 0:13
sussChristian in a nice hotel in Singapore24-Apr-05 0:13 
Generalbyte[] to string and back again... Pin
Ian Bowler22-Apr-05 10:49
Ian Bowler22-Apr-05 10:49 
Hello,

Here's my problem: I have to replace all instances of a certain string in binary values. I was using ASCIIEncoding to get the bytes to a string, performing the replace, then using ASCIIEncoding to get the string back to byte[]. This was working for most of my tests but then I ran into binary values that were getting corrupted during the conversion. I wrote the following test code:

// myRegKey is a RegistryKey object
// ValueName is a string (the name of the value I want to retrieve from the registry)

object valData = myRegKey.GetValue(ValueName);
ASCIIEncoding ae = new ASCIIEncoding();
byte[] buff = (byte[])valData;
string tmp = ae.GetString(bite);
byte[] buff2 = ae.GetBytes(tmp);

So I would expect that buff and buff2 would be identical, but they are not!

I need a way to get a byte[] to a string and then back to a byte[] without compromising my data. Any ideas?

Perhaps if someone had a method that converts a binary value to a string of hex digits? For example, "Hello World!" would become "48656C6F20576F726C6421"

Thanks,

-Ian




GeneralRe: byte[] to string and back again... Pin
CiNN22-Apr-05 20:32
CiNN22-Apr-05 20:32 
GeneralRe: byte[] to string and back again... Pin
leppie22-Apr-05 21:03
leppie22-Apr-05 21:03 
GeneralgetByte Pin
Anonymous22-Apr-05 10:10
Anonymous22-Apr-05 10:10 
GeneralRe: getByte Pin
Le centriste25-Apr-05 4:37
Le centriste25-Apr-05 4:37 
GeneralSaving image Pin
wetdog50022-Apr-05 9:23
wetdog50022-Apr-05 9:23 
GeneralRe: Saving image Pin
Polis Pilavas22-Apr-05 9:46
Polis Pilavas22-Apr-05 9:46 
GeneralRe: Saving image Pin
wetdog50022-Apr-05 9:54
wetdog50022-Apr-05 9:54 
GeneralRe: Saving image Pin
Polis Pilavas22-Apr-05 9:58
Polis Pilavas22-Apr-05 9:58 
GeneralRe: Saving image Pin
wetdog50022-Apr-05 10:09
wetdog50022-Apr-05 10:09 
GeneralRe: Saving image Pin
Polis Pilavas22-Apr-05 10:21
Polis Pilavas22-Apr-05 10:21 
GeneralRe: Saving image Pin
wetdog50022-Apr-05 10:30
wetdog50022-Apr-05 10:30 
GeneralRe: Saving image Pin
Polis Pilavas22-Apr-05 10:40
Polis Pilavas22-Apr-05 10:40 
GeneralRe: Saving image Pin
wetdog50022-Apr-05 10:51
wetdog50022-Apr-05 10:51 
GeneralRe: Saving image Pin
Polis Pilavas22-Apr-05 10:53
Polis Pilavas22-Apr-05 10:53 
GeneralRe: Saving image Pin
jinzhecheng23-Apr-05 9:00
jinzhecheng23-Apr-05 9:00 
GeneralCool: MessageBox.Show(3.1415927.ToString()); Pin
Member 9622-Apr-05 8:04
Member 9622-Apr-05 8:04 
GeneralRe: Cool: MessageBox.Show(3.1415927.ToString()); Pin
turbochimp22-Apr-05 8:28
turbochimp22-Apr-05 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.