有人可以帮我找到最多的字符串吗?这是代码:
if (dt.Rows.Count > 0)
{
int max = 0;
foreach (DataRow dr in dt.Rows)
{
bookNo = dr.ItemArray[0].ToString();
int i = Convert.ToInt32(bookNo.Substring(bookNo.Length - 1));
if (i > max)
{
}
}
由于
答案 0 :(得分:2)
你可以在单行
中完成int max = dt.Rows
.Select(x=>Convert.ToInt32(x.ItemArray[0].ToString().Substring(bookNo.Length-1)))
.Max();