// Tarihleri Siralama | www.yazilimcik.com
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;
// Tarihleri Siralama | www.yazilimcik.com
namespace Tarih_Siralamasi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// DateTime Tipinde 10 Elemanli Bir Dizi Olusturalim:
DateTime[] tarihler = new DateTime[10];
int i;
private void Form1_Load(object sender, EventArgs e)
{
string deger = txtDeger.Text;
btnBuyuk.Enabled = false;
listBox1.Items.Remove(deger);
txtDeger.Focus();
}
private void btnTarih_Click(object sender, EventArgs e)
{
string deger = txtDeger.Text;
try
{
if (deger != null || deger != "")
{
tarihler[i] = Convert.ToDateTime(deger);
listBox1.Items.Add(deger);
i++;
}
txtDeger.Clear();
txtDeger.Focus();
btnBuyuk.Enabled = true;
btnBuyuk.ForeColor = Color.Green;
btnBuyuk.BackColor = Color.LightGreen;
}
catch (Exception)
{
MessageBox.Show("Lütfen Bir Tarih Yazip ’Tarih Girisi’ Butonuna Basin..!", "Bilgi:");
txtDeger.Clear();
txtDeger.Focus();
}
}
private void btnBuyuk_Click(object sender, EventArgs e)
{
string deger = txtDeger.Text;
try
{
if (listBox1.Items.Count != 0)
{
Array.Sort(tarihler);
Array.Reverse(tarihler);
lblSonuc.Text = tarihler[0].ToShortDateString();
deger = string.Empty;
txtDeger.Focus();
}
else
{
MessageBox.Show("Lütfen Bir Tarih Yazip ’Tarih Girisi’ Butonuna Basin..!", "Bilgi:");
txtDeger.Clear();
txtDeger.Focus();
}
}
catch (Exception)
{ }
}
}
}
// Tarihleri Siralama | www.yazilimcik.com