Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
GeneralOnProgressChange Pin
monrobot131-Apr-03 13:50
monrobot131-Apr-03 13:50 
GeneralRe: OnProgressChange Pin
Stephane Rodriguez.3-Apr-03 1:33
Stephane Rodriguez.3-Apr-03 1:33 
GeneralImagelist Problems Pin
CSharpDavid1-Apr-03 11:46
CSharpDavid1-Apr-03 11:46 
GeneralRe: Imagelist Problems Pin
James T. Johnson2-Apr-03 1:53
James T. Johnson2-Apr-03 1:53 
QuestionConvert String to byte[] and vice versa? Pin
Member 961-Apr-03 11:27
Member 961-Apr-03 11:27 
AnswerRe: Convert String to byte[] and vice versa? Pin
Nick Parker1-Apr-03 11:34
protectorNick Parker1-Apr-03 11:34 
GeneralRe: Convert String to byte[] and vice versa? Pin
Member 961-Apr-03 11:43
Member 961-Apr-03 11:43 
GeneralRe: Convert String to byte[] and vice versa? Pin
Member 961-Apr-03 12:41
Member 961-Apr-03 12:41 
Actually, I found that it's much more complicated than that when I tried it. Your method using bitconverter returns a string of text that represents the bytes (i.e. "12-24-fe" etc). What I wanted to do is go from unicode text to byte array then back to unicode text.

I did some scratching around and found that this works although it might not be optimal:

<br />
//<---ENCODE (turn into bytes) ---><br />
//Start with a string<br />
			string sInput="The quick brown fox jumped over the six lazy dogs!";<br />
			<br />
			//convert it from unicode to an array of bytes<br />
			byte[] b = Encoding.Unicode.GetBytes(sInput.ToCharArray());<br />
<br />
			//<---DECODE (turn into unicode text)---><br />
<br />
			//Get a decoder object for unicode arrays<br />
			Decoder d = Encoding.Unicode.GetDecoder();<br />
<br />
			//Create a character array to hold the results of the decode<br />
			//(because decoder doesn't decode directly to a string)<br />
			char[] ch= new char[d.GetCharCount(b,0,b.GetLength(0))];<br />
<br />
			//Decode the bytes to string<br />
			d.GetChars(b,0,b.GetLength(0),ch,0);<br />
<br />
			//Construct a new string from the character array<br />
            string sOut=new string(ch);<br />
<br />
			//that's it.  SOut now contains original sInput string

GeneralRe: Convert String to byte[] and vice versa? Pin
David Stone1-Apr-03 17:04
sitebuilderDavid Stone1-Apr-03 17:04 
GeneralRe: Convert String to byte[] and vice versa? Pin
Member 961-Apr-03 18:34
Member 961-Apr-03 18:34 
AnswerRe: Convert String to byte[] and vice versa? Pin
Alexander Kojevnikov1-Apr-03 20:49
Alexander Kojevnikov1-Apr-03 20:49 
QuestionCreating MS Access Database? Pin
BM_CSharp1-Apr-03 11:01
sussBM_CSharp1-Apr-03 11:01 
QuestionHow to assign executable's icon Pin
Mmithat1-Apr-03 9:00
Mmithat1-Apr-03 9:00 
AnswerRe: How to assign executable's icon Pin
Chris Jobson1-Apr-03 11:09
Chris Jobson1-Apr-03 11:09 
AnswerRe: How to assign executable's icon Pin
CSharpTeam1-Apr-03 11:09
CSharpTeam1-Apr-03 11:09 
GeneralLISTBOX How to select more than one entry at the startup Pin
Mmithat1-Apr-03 8:26
Mmithat1-Apr-03 8:26 
GeneralRe: LISTBOX How to select more than one entry at the startup Pin
Chris Jobson1-Apr-03 11:02
Chris Jobson1-Apr-03 11:02 
GeneralRe: LISTBOX How to select more than one entry at the startup Pin
Mmithat1-Apr-03 12:30
Mmithat1-Apr-03 12:30 
Generala .Net portal Pin
Madhuri Mittal1-Apr-03 7:01
Madhuri Mittal1-Apr-03 7:01 
GeneralRe: a .Net portal (clickety police :) ) Pin
Ray Cassick1-Apr-03 8:54
Ray Cassick1-Apr-03 8:54 
GeneralRe: a .Net portal (clickety police :) ) Pin
Madhuri Mittal1-Apr-03 9:37
Madhuri Mittal1-Apr-03 9:37 
GeneralNondismissable form Pin
B.W.1-Apr-03 4:55
B.W.1-Apr-03 4:55 
GeneralRe: Nondismissable form Pin
Le centriste1-Apr-03 6:40
Le centriste1-Apr-03 6:40 
GeneralRe: Nondismissable form Pin
James T. Johnson1-Apr-03 7:02
James T. Johnson1-Apr-03 7:02 
GeneralComponents Pin
victorb1-Apr-03 4:04
victorb1-Apr-03 4:04 

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.