Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
1
Indexable
Never
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        List<int> sayilar = new List<int>();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        void Olustur() {
            Random rnd = new Random();
            for (int i = 0; i < 10; i++)
            {
                sayilar.Add(rnd.Next(-20, 20));
            }
        }

        void Temizle() {
            textBox1.Text = "";
            textBox2.Text = "";
            sayilar.Clear();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Temizle();
            Olustur();

            foreach (int sayi in sayilar)
                textBox1.Text += sayi + " ";

            var ciftler = from n in sayilar where n % 2 == 0 orderby n * n descending select n * n;
            foreach (int sayi in ciftler)
                textBox2.Text += sayi + " ";
        }

     

    }
}