简体   繁体   English

string.join添加一些计数并休息到换行符

[英]string.join to append with some count and take rest to newline

I am using string.join appending many data which is separated by comma.If we have more than 50,only first 10 are visible and others are not visible.It will exit the screen size.I want to display the data with some count in string within screen. 我正在使用string.join追加许多用逗号分隔的数据。如果我们有50多个,则仅前10个可见,而其他不可见。它将退出屏幕尺寸。我想在其中显示一些计数的数据屏幕内的字符串。

_validatonDictionary.AddError(string.Empty, string.Join(",", findduplicate) + "-Settlement POD," + string.Join(",", finddupl) + "-Ded are duplicate PODS");

"findduplicate" and "finddupl" is the list which consist of more than 100 item.I want to diplay maximum 10 one after other “ findduplicate”和“ finddupl”是由100多个项目组成的列表。我想最多显示一个10

You can use Ceiling 您可以使用天花板

//Calculating number of loops to run
int ceilingLimit = 10;
int iCount = finddupl.Count() / ceilingLimit + (finddupl.Count() % ceilingLimit != 0 ? 1 : 0);;
for (int iLoopCount = 0; iLoopCount < iCount; ++iLoopCount)
{
     int iRecordCount = finddupl.Count() >= ceilingLimit ? ceilingLimit : finddupl.Count();
     var currentDupls = finddupl.Take(iRecordCount).ToList();
     _validatonDictionary.AddError(string.Empty, string.Join(",", findduplicate) + "-Settlement POD," + string.Join(",", currentDupls) + "-Ded are duplicate PODS");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM