Alex_is_coding
Alex_is_coding
CC#
Created by Jason_Bjorn on 6/27/2024 in #help
LINQ help
I was curious to try, and got this
int[] numbers = { 80, 120, 110, 90, 10, 140, 150, 50, 22, -800 };

IOrderedEnumerable<int> sortedNum = numbers.OrderDescending();
string aStr = string.Empty;
for(int i = 0; i <= 2; i++)
{
if (sortedNum.ElementAt(i) >= 100)
{
aStr += sortedNum.ElementAt(i).ToString() + "\r\n";
}
}
MessageBox.Show( aStr );
int[] numbers = { 80, 120, 110, 90, 10, 140, 150, 50, 22, -800 };

IOrderedEnumerable<int> sortedNum = numbers.OrderDescending();
string aStr = string.Empty;
for(int i = 0; i <= 2; i++)
{
if (sortedNum.ElementAt(i) >= 100)
{
aStr += sortedNum.ElementAt(i).ToString() + "\r\n";
}
}
MessageBox.Show( aStr );
26 replies