ใช้ Random.Next(minValue, maxValue) สุ่มตัวเลขในช่วง
Random rd = new Random(); int rand_num = rd.Next(100, 200);
ตัวอย่าง
using System;
class Program {
static void Main() {
Random rd = new Random();
int rand_num = rd.Next(100, 200);
Console.WriteLine(rand_num);
}
}
ผลลัพธ์
182