 |
|
รบกวนช่วยแนะนำหน่อยครับ ผมจะหาค่าสูงสุด ออกมา 3 ค่า |
|
 |
|
|
 |
 |
|
http://www.csharp-examples.net/sort-array/
http://stackoverflow.com/questions/1301822/how-to-sort-an-array-of-object-by-a-specific-field-in-c
|
 |
 |
 |
 |
Date :
2016-05-17 19:49:37 |
By :
deksoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2016-05-17 19:50:52 |
By :
evotionzz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
int[] x = { 30, 50, 40, 20, 80 };
var desc = from s in x orderby s descending select s;
int i = 0;
foreach (int y in desc)
{
i++;
Console.WriteLine(y);
if (i== 3)
{
return;
}
}
|
ประวัติการแก้ไข 2016-05-17 20:08:30 2016-05-17 20:09:04 2016-05-17 20:10:05
 |
 |
 |
 |
Date :
2016-05-17 20:07:42 |
By :
bigsuntat |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
int[] x = { 30, 50, 40, 20, 80 };
Array.Sort(x);
Array.Reverse(x);
for (int i = 0; i < 3; i++)
{
Console.WriteLine(x[i]);
Console.Read();
}
|
 |
 |
 |
 |
Date :
2016-05-17 21:39:45 |
By :
bigsuntat |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา Console.Read(); ออกนอก Loop ครับ
|
 |
 |
 |
 |
Date :
2016-05-17 22:59:32 |
By :
bigsuntat |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|