[英]How to Find the Greatest and lowest value in listbox
I am new in c#, 我是C#新手,
I am using these to find the greatest and lowest value . 我用这些来找到最大和最小的价值。
int[] numbers = new[] { 1,2,3,4,5 };
int min = numbers.Min();
int max = numbers.Max();
I want to find the greatest and lowest value from list box by something like this 我想从列表框中找到最大和最小的值,像这样
int[] numbers = new[] { listbox1.items };
int min = numbers.Min();
int max = numbers.Max();
There would be great appreciation if someone could help me. 如果有人可以帮助我,将不胜感激。
Thanks In Advance. 提前致谢。
try this: 尝试这个:
var numbers = listBox1.Items.Cast<object>().Select(obj => Convert.ToInt32(obj));
int min = numbers.Min();
int max = numbers.Max();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.