String to byte [] and vice versa?

Possible duplicate:
.NET String for C # byte Array

How to convert a String array to byte [] and vice versa? I need strings to be stored in binary storage. Please show an example in both directions. And one more thing: each line can be more than 90 KB.

+5
source share
4 answers

If you want to use UTF-8 encoding:

// string to byte[]
byte[] bytes = Encoding.UTF8.GetBytes(someString);

// byte[] to string
string anotherString = Encoding.UTF8.GetString(bytes);
+18
source

, , , , . ( ) encoding, . .

, , , .

+8
+3

All Articles