Converts a string to an array of bytes - CSharp System

CSharp examples for System:Byte Array

Description

Converts a string to an array of bytes

Demo Code



public class Main{
        /// <summary>
      /// Converts a string to an array of bytes
      /// </summary>
      /// <param name="sourceString">The string to be converted</param>
      /// <returns>The new array of bytes</returns>
      public static byte[] ToByteArray(System.String sourceString)
      {//  www . ja v  a2  s  . c  o  m
         return System.Text.UTF8Encoding.UTF8.GetBytes(sourceString);
      }
}

Related Tutorials