Get String from byte array - CSharp System

CSharp examples for System:Byte Array

Description

Get String from byte array

Demo Code


using System;/*from   w ww . ja v a 2 s . co m*/

public class Main{
        public static string GetString(byte[] bytes)
        {
            var stringLen = bytes.Length / sizeof(char);
            var chars = new char[stringLen];
            Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
            return new string(chars);
        }
}

Related Tutorials