SoFunction
Updated on 2025-03-07

C# implements a simple implementation method for converting strings into byte arrays

This article describes a simple implementation method for C# to convert strings into byte arrays. Share it for your reference. The specific implementation method is as follows:

using ;
public static byte[] ConvertStringToByteArray(string stringToConvert)
{
  return (new UnicodeEncoding()).GetBytes(stringToConvert);
}

I hope this article will be helpful to everyone's C# programming.