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);
        }

 

posted @ 2016-10-21 11:09  公众号python学习开发  阅读(1105)  评论(0编辑  收藏  举报