Converts byte[] to string. - CSharp System

CSharp examples for System:Byte

Description

Converts byte[] to string.

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;// ww w .  ja  v  a 2 s  .  c om

public class Main{
        /// <summary>
        ///     Converts byte[] to string.
        /// </summary>
        /// <param name="buff">Byte[] to be converted</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <returns>The string that represents the byte[]</returns>
        public static string ByteToString(IEnumerable<byte> buff)
        {
            return buff.Aggregate("", (current, t) => current + t.ToString("X2"));
        }
}

Related Tutorials