
Convert Strings to Byte arrays and back
A lot of this stuff in .NET isn't explained well enough in MSDN to
immediately see how something works. I just play around with the different
parts of it and I make mental notes of things as I learn them.
Unfortunately, there's no real science about it. .NET is so different from
before that it's just going to take time for us to learn all the little
details. :-)
Take care,
Brian Bischof, CPA, MCSD, MCT
"The .NET Languages: A Quick Translation Guide"
www.bischofsystems.com/vbnet.asp
Quote:
> What I couldn't figure out was to use DEFAULT.
> How did you know to use the Default? I couldn't find anything on MSDN
> stating that.
> Everything I found only showed Encoding.getbytes() which didn't work.
> Just trying learn
> Randy
> > Hey Randy,
> > Here is a quick code example I wrote that coverts from a string to byte
> > array and back.
> > Dim s As String
> > Dim b() As Byte
> > s = "Hello"
> > b = System.Text.Encoding.Default.GetBytes(s)
> > s = ""
> > s = System.Text.Encoding.Default.GetString(b)
> > MessageBox.Show(s)
> > I hope this helps,
> > Brian Bischof, CPA, MCSD, MCT
> > "The .NET Languages: A Quick Translation Guide"
> > www.bischofsystems.com/vbnet.asp
> > > Hello,
> > > I need to convert strings to byte arrays and also byte arrays back to
> > > strings.
> > > Can anyone tell me how to do this or point me to some code.
> > > I've been trying to use ASCIIEncoding.GetBytes but I can't get it
work.
> I
> > > don't understand
> > > how I need to use it.
> > > Help
> > > Thanks Randy