CSharp examples for System:String Encode Decode
Decodes and returns the parameter Value stored in the specified Stream.
using System.IO;/*from w ww .j a va2 s .c o m*/ using System.Diagnostics; using System; public class Main{ public static String Decode(Stream stream, int maxSize) { byte[] buf = stream.ReadBytes(maxSize); return Decode(buf); } public static String Decode(byte[] buffer, int startPos) { throw new NotImplementedException(); } /// <summary> /// Decodes and returns the parameterValue stored in the specified bufferStream. /// </summary> /// <param name="bufferStream">the bufferStream containing the encoded parameterValue /// </param> /// <returns> the decoded parameterValue /// </returns> public static String Decode(byte[] buffer) { string rst = System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length); int nullLoc = rst.IndexOf('\0'); if (nullLoc > -1) rst = rst.Substring(0, nullLoc); return rst; } }