内容输出为每行的字符串的方法

一、

        public static List<string> GetTxtListByContent(string content, bool withBlank = false)
        {
            content = content.Replace("
", "
");
            content = content.Replace("
", "
");
            if (!withBlank)
            {
                content = content.Replace("


", "
");
                content = content.Replace("

", "
");
            }
            string[] array = Regex.Split(content, "
", RegexOptions.IgnoreCase);
            var list = new List<string>(array);
            return list;
        }

二、

        public static List<string> ReadAllLineOfString(string contnet)
        {
            var lines = new List<string>();
            using (StringReader sReader = new StringReader(contnet))
            {
                string line;
                while ((line = sReader.ReadLine()) != null)
                {
                    lines.Add(line);
                }
            }
            return lines;
        }
原文地址:https://www.cnblogs.com/dayang12525/p/10025265.html