Shamil Salakhetdinov
shamil at smsconsulting.spb.ru
Tue Oct 13 15:20:31 CDT 2009
From: Shamil Salakhetdinov [mailto:shamil at smsconsulting.spb.ru] Sent: Wednesday, October 14, 2009 12:13 AM To: 'Discussion concerning Visual Basic and related programming issues.' Subject: FW: JSON and XML in memory serialization sample code (Part 3) Continued from Part 2. /// <summary> /// Converts strings to byte arrays and vice versa /// </summary> public class StringToBytes { /// <summary> /// Converts a Byte Array of Unicode values (UTF-8 encoded) to a complete String. /// </summary> /// <param name="characters">Unicode Byte Array to be converted to String</param> /// <returns>String converted from Unicode Byte Array</returns> public static String UTF8ByteArrayToString(Byte[] characters) { UTF8Encoding encoding = new UTF8Encoding(); String constructedString = encoding.GetString(characters); return (constructedString); } /// <summary> /// Converts the String to UTF8 Byte array and is used in De serialization /// </summary> /// <param name="pXmlString"></param> /// <returns></returns> public static Byte[] StringToUTF8ByteArray(String pXmlString) { UTF8Encoding encoding = new UTF8Encoding(); Byte[] byteArray = encoding.GetBytes(pXmlString); return byteArray; } } To be continued in Part 3.2..