تولید عدد تصادفی و مرتب سازی
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;
using System.Collections;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int sum;
private void Form1_Load(object sender, EventArgs e)
{
Random Number = new Random();
ArrayList rnd = new ArrayList();
for (int i = 0; i <= 10; i++)
{
rnd.Add(Number.Next(100));
listBox1.Items.Add(rnd[i]);
}
rnd.Sort();
for (int i = 0; i <= 10; i++)
{
listBox2.Items.Add(rnd[i]);
}
for (int i = 0; i <= 10; i++)
{
sum+=Convert.ToInt32( listBox2.Items[i]);
}
label1.Text = sum.ToString();
}
}
}
نظرات شما عزیزان: