Geeks With Blogs
Sharvan Dhaka blog
Convert a string to a byte array

string myString = "a test string";
byte[] myByteArray = new byte[myString.Length];
int i = 0;
foreach(char c in InStr.ToCharArray())
myByteArray [i] = (byte)c;

Convert a byte array to a string

System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] myByteArray = enc.GetBytes("a text string);
string myString = enc.GetString(myByteArray );
Posted on Sunday, October 15, 2006 5:42 PM , c# , Tricky Solution/ Code | Back to top

Comments on this post: How to convert a string to a byte array and convert a byte array to a string c#

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Sharvan Dhaka | Powered by: