找到最大的数字 [英] Find the greatest Number
本文介绍了找到最大的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮我找到最多的字符串吗?这是代码:
if (dt.Rows.Count < span class =code-keyword>> 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)
{
}
}
谢谢
解决方案
< pre lang =cs> if (i > max)
{
max = i;
}
只需写一下
max = i;
在if语句中。然后在循环结束时,max将包含最大值。
将所有数据放入通用List< int> &安培;调用最大列表方法。
列表< int > iList = new List < int > ();
//这里将值添加到iList
int iMax = iList.Max();
Hi,
Please could someone help me find the greatest number of a string? Here's the code:
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)
{
}
}
Thanks
解决方案
if (i > max) { max = i; }
Just write
max = i;
Inside the "if" statement. then at the end of your loop, max will contain the maximum value.
place your all data in generic List<int> & call max method of list.
List<int> iList = new List<int>(); //Here add values into iList int iMax = iList.Max();
这篇关于找到最大的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文