Extension for convert a string to stream

    0

    1

    lucycodes42

    C# recipes

    This code converts a string to a byte array and returns a new memory stream.

    Shortcut: ex_string_to_stream

    public static System.IO.Stream ConvertToStream(this string source)
    {
      var byteArray = System.Text.Encoding.UTF8.GetBytes(source);
      return new System.IO.MemoryStream(byteArray);
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.