|  | 
| c# | 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int a;
            a = toplama(2, 15);
            label1.Text = a.ToString();
            rastgelesayi(5, 15);
        }
        int toplama (int x , int y )
            {
                int t = 0;
                for (int i = x; i <= y; i++)
                {
                    t = t + i;
                }
                return t; 
        }
        void rastgelesayi(int a, int b)
        {
            Random r = new Random();
            for (int i = 1; i <= 10; i++)
            {
                int s;
                s = r.Next(a, b);
                listBox1.Items.Add(s);
            }
        }
    }
}
 
0 yorum :
Yorum Gönder