تولید عدد تصادفی
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double sum;
private void Form1_Load(object sender, EventArgs e)
{
int i;
int[] a = new int[10];
Random r = new Random();
Random r1 = new Random(r.Next());
for (i = 0; i < a.Length; i++)
{
a[i] = r1.Next(100);
}
for (i = 0; i < a.Length; i++)
{
a[i] = r1.Next(100);
listBox1.Items.Add(a[i]);
sum += a[i];
}
label1.Text += sum.ToString();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
نظرات شما عزیزان: