How do I convert String to byte[] array and vice versa? I need strings to be stored in some binary storage. Please show example in both directions. And one more thing: each string maybe bigger than 90Kb.
Answer
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);
No comments:
Post a Comment