c#按照指定长度切分字符串
2021-05-04 00:30
标签:size 字符 int lin mat ceiling page -- add int pageSize=5; var array = new List ----------方法1-------------------- c#按照指定长度切分字符串 标签:size 字符 int lin mat ceiling page -- add 原文地址:http://www.cnblogs.com/simadi/p/7728664.html
var pageCount = (int)Math.Ceiling(1.0 * small.Length / pageSize);
for (int i = 0; i {
var bb = small1.Skip(i * pageSize).Take(pageSize).ToArray();
array.Add(new string(bb));
}
----------方法2--------------------
var i = 0;
while (small1.Length>i)
{
var str = small1.Substring(i, Math.Min(pageSize, small1.Length-i));
array.Add(str);
i = i + pageSize;
}