Here is two methods for string to Byte[]
Method 1
----------
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
Method 2
----------
byte[] byteArray = Encoding.UTF8.GetBytes(stringValue);
Byte[] to String
----------------
byte [] dBytes = ...
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(dBytes);
...S.VinothkumaR.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment