|
 |
|
ถามเกี่่ยวกับการสุ่มตัวเลขแบบไม่ซ้ำ และสลับค่าใน array [Visual C#] |
|
 |
|
|
 |
 |
|
ถ้าสุ่มตัวเลข
Random rnd = new Random();
int num = rnd.Next(50);
txtOut.text = num.tostring();
==================================================
การใช้เมธอด Sort()
Sort() เป็นการจัดเรียงอาร์เรย์จากน้อยไปมาก
ตัวอย่าง
Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
int[ ] a = { 56, 43, 75, 32, 88, 32 };
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i] + "\n");
}
Console.WriteLine("After Sort");
Array.Sort(a);
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i] + "\n");
}
Console.ReadLine();
}
}
}
ถ้าถูกใจกดขอบคุณทีนะครับ
|
ประวัติการแก้ไข 2010-09-20 01:02:31 2010-09-20 01:06:30 2010-09-20 01:18:52
 |
 |
 |
 |
Date :
2010-09-20 01:01:15 |
By :
nooknoname |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
      
|
 |
 |
 |
 |
Date :
2014-03-12 12:42:21 |
By :
001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
              
|
 |
 |
 |
 |
Date :
2014-03-12 12:43:47 |
By :
1010 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|