zoukankan      html  css  js  c++  java
  • C# byte数组转换成List<String>

    byte[] bys=buffer;

     string[] AllDataList=  Encoding.Default.GetString(bys).Split(Environment.NewLine.ToCharArray());

    Encoding.Default.GetString(bys) 表示byte[]转成string。

    Split(Environment.NewLine.ToCharArray());  表示按照换行符进行split成string数组。

    ------------------------------------------------------------------------------------

    protected override void Execute(CodeActivityContext context)
            {
                byte[] buffer = context.GetValue(inBuffer);
                Encoding encod = context.GetValue(inEncoding);
                List<string> list = new List<string>();
                
                using (MemoryStream ms = new MemoryStream(buffer))
                {                

                    using (StreamReader sr = new StreamReader(ms, encod))
                    {
                        while (sr.Peek() != -1)
                        {
                            list.Add(sr.ReadLine());
                        }
                    }
                }

                context.SetValue(outListField, list);
            }

  • 相关阅读:
    ntp时钟同步
    io,进程监控
    Linux下修改主机名
    DataGuard主库增加联机日志
    external table
    linux卸载HBA卡驱动
    Oracle DataGuard延迟应用归档归档日志
    index unusable
    VBOX 克隆虚拟机
    device eth0 has different MAC address than expected,igoring
  • 原文地址:https://www.cnblogs.com/c-x-a/p/5983851.html
Copyright © 2011-2022 走看看