Convert String To Bytes - CSharp System

CSharp examples for System:Byte

Description

Convert String To Bytes

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/* w  ww .jav a 2 s.co  m*/

public class Main{
        public static byte[] ConvertStringToBytes(string str)
      {
         return str.ToArray().Select(s => (byte)s).ToArray();
      }
}

Related Tutorials