This code sample shows how to convert a string to a byte array and and byte array to string.
//function to convert string to byte array
public static byte[] ConvertStringToByteArray(string stringToConvert)
{
return (new UnicodeEncoding()).GetBytes(stringToConvert);
}
//function to convert byte array to string
public static string ConvertByteArrayToString(byte[] byteArray)
{
return (new UnicodeEncoding()).GetString(byteArray);
}
Wednesday, August 8, 2007
Subscribe to:
Post Comments (Atom)
Review Books
- ASP.NET WebService
- Learn VisualStudio.net
- Basic .NET Framework
- Basic C#
- .NET Interview Questions
- C# 2005 Programming
No comments:
Post a Comment