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
    {
        public Form1()
        {
           
InitializeComponent();                 
        }
        string[] meyvalar = new
string[100];
        int i = 0;
        int meyvavar = 0;// bayrak
görevini görür.
        private void
button1_Click(object sender, EventArgs e)
        {
            for (int sayaç = 0; sayaç < i; sayaç++)
            {
               
if (meyvalar[sayaç] == textBox1.Text)
               
{
                   
MessageBox.Show("bu meyva daha önce eklendi");
                   
textBox1.Text = "";
meyvavar = 1;// daha önce meyve girilmiştir anlamına
geliyor.
               
}
            }
            if (meyvavar == 0) // daha önce
aynı meyve girilmemişse eğer anlamına geliyor.
            {
               
listBox1.Items.Add(textBox1.Text); 
               
meyvalar[i] = textBox1.Text;
               
textBox1.Text="";
            }
           
meyvavar=0;
           
i++;
        }
    }
}

Hiç yorum yok:
Yorum Gönder