Decodes and returns the parameter Value stored in the specified buffer Stream. - CSharp System

CSharp examples for System:String Encode Decode

Description

Decodes and returns the parameter Value stored in the specified buffer Stream.

Demo Code


using System.IO;//from   www .  j av  a 2  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*2);
            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)
        {
            return System.Text.Encoding.Unicode.GetString(buffer, 0, buffer.Length).TrimEnd(new char[] { (char)0 });
        }
}

Related Tutorials