Professional Documents
Culture Documents
MessageBox.Show(dizi[0].ToString() + dizi[1].ToString());
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
bool durum = a == b;
if (durum == false)
MessageBox.Show("sayılar eşit değil!");
else MessageBox.Show("sayılar eşit:)");
int a = int.Parse(textBox1.Text);
int b = int.Parse(textBox2.Text);
bool durum = a == b;
MessageBox.Show(durum.ToString());
object a = textBox1.Text;
object b = textBox2.Text;
object c = a.ToString() + b.ToString();
MessageBox.Show(c.ToString());
int a = 3;
int b = 2;
int c = (int)a / b;
MessageBox.Show(c.ToString());
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace deneme_3.hafta
{
public partial class Form1 : Form
{
Bu kısımda struct değişkenini açıklamak için değişken tanımladık.
Burada public değerini kullandığımıza dikkat edin.
}
public Form1()
{
InitializeComponent();
}
}
}
}
FONKSĐYON YAPISINI ANLAMA
BUTTON’A CLICK OLARAK VERMEK ĐLE ALAN BULUNABĐLĐR.AMA BUNU FONKSĐYON OLARAK
TANIMLAMAK DAHA KULLANILABĐLĐR OLUR.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace deneme_3.hafta
{
public partial class Form1 : Form
{
public int dikdörtgenin_alanı(int yükseklik, int boy)
{int alan=yükseklik*boy;
return alan;
}
public Form1()
{
InitializeComponent();
}
}
}
}
FONKSĐYON YAPISINI OLUŞTURARAK TEXTBOXTAN DEĞER ALARAK PROGRAM YAZMA
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace deneme_3.hafta
{
public partial class Form1 : Form
{
public int dikdörtgenin_alanı(int yükseklik, int boy)
{int alan=yükseklik*boy;
return alan;
}
public Form1()
{
InitializeComponent();
}
}
}
}
4.HAFTA DERSĐ:KARŞILAŞTIRMA KOMUTLARI
FONKSĐYON YAPISINI OLUŞTURARAK TEXTBOXTAN DEĞER ALARAK PROGRAM YAZMA
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _4.hafta_deneme
{
public partial class Form1 : Form
{
public decimal üçgenin_alanı(decimal a, decimal h)
{
decimal alan;
alan = (a * h) / 2;
return alan;
}
public Form1()
{
InitializeComponent();
}
ĐF YAPISI
Kullanımı:
If (karşılaştırma)
{Eğer karşılaştırma doğru ise}
Else
{Eğer karşılaştırma yanlış ise}
if (comboBox1.SelectedItem.ToString() == "ESKĐŞEHĐR")
{
MessageBox.Show("Seçtiğiniz il eskişehirdir.");
}
else
{
MessageBox.Show("Farklı bir il seçtiniz");
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _4.hafta_deneme
{
public partial class Form1 : Form
{
public decimal üçgenin_alanı(decimal a, decimal h)
{
decimal alan;
alan = (a * h) / 2;
return alan;
}
public Form1()
{
InitializeComponent();
}
}
}
}
VE KULLANARAK ĐF DÖNGÜSÜ KULLANARAK PROGRAM YAZMA
int a = int.Parse(textBox1.Text);
int b=int.Parse(textBox2.Text);
bool durum;
durum = a > b;
if (durum)
MessageBox.Show("Birinci sayı ikinci sayıdan büyük");
UNUTULMAMASI GEREKEN BAZI KARŞILAŞTIRMALAR
Bağlaçlar
Ve “&&”
Veya “||”
namespace _4.hafta_deneme
{
public partial class Form1 : Form
{
public decimal üçgenin_alanı(decimal a, decimal h)
{
decimal alan;
alan = (a * h) / 2;
return alan;
}
public Form1()
{
InitializeComponent();
}
}
}
DEFAULT KOMUTU
Burada komutla seçim dışı bırakılan bir eleman için default kullanılır.
{
switch (comboBox1.SelectedItem.ToString())
{case "ESKĐŞEHĐR":
MessageBox.Show("ĐL ESKĐŞEHĐR");
break;
case "ANKARA":
MessageBox.Show("ĐL ANKARA");
break;
default:
MessageBox.Show("BAŞKA BĐR ĐL SEÇĐLDĐ");
break;
}
ĐKĐ CASE DEĞERĐNĐ BĐR ARADA KULLANMA
{
switch (comboBox1.SelectedItem.ToString())
{case "ESKĐŞEHĐR":
case "ANKARA":
MessageBox.Show("BÖLGE ĐÇ ANADOLU");
break;
case "RĐZE":
MessageBox.Show("KARADENĐZ BÖLGESĐ");
break;
default:
MessageBox.Show("BAŞKA BĐR ĐL SEÇĐLDĐ");
break;
{
if (comboBox1.SelectedItem.ToString() == "ESKĐŞEHĐR")
goto ESKĐŞEHĐR;
MessageBox.Show("ATLANAN YER");
ESKĐŞEHĐR:
MessageBox.Show("Đl ESKĐŞEHĐR");
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _5.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
else
{label5.Text="Başarısız";
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _5.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _5.hafta
{
public partial class Form1 : Form
{
public decimal toplam;
public Form1()
{
InitializeComponent();
}
if(kalan!=0)
{
toplam = toplam + sayaç;
}
}
textBox1.Text = toplam.ToString();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _5.hafta
{
public partial class Form1 : Form
{
public decimal toplam;
public Form1()
{
InitializeComponent();
}
}
}
}
6.hafta
sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
8.hafta çalışması
HATA YAKALAMA
Try-catch metodu ve hata yakalama
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i, j;
i = int.Parse(textBox1.Text);
j = int.Parse(textBox2.Text);
if(i>100||i<0)
{
throw new Exception("Not sıfır ile yüz arasında
olmalıdır.");
}
decimal k = (decimal)i / j;
label1.Text = k.ToString();
}
catch(Exception hata)
{
MessageBox.Show(hata.Message);
}
}
}
}
Finally bloğu
(Hata olsa da olmasa da çalışır)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i, j;
i = int.Parse(textBox1.Text);
j = int.Parse(textBox2.Text);
if (i > 100 || i < 0)
{
throw new Exception("Not sıfır ile yüz arasında
olmalıdır.");
}
decimal k = (decimal)i / j;
label1.Text = k.ToString();
}
catch (Exception hata)
{
MessageBox.Show(hata.Message);
}
finally
{
MessageBox.Show("Program çalıştı!");
}
}
}
}
Basit bir şifreleme programı
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
int sayaç = 0;
public Form1()
{
InitializeComponent();
}
if (password1==password)
{ throw new Exception("Programa hoşgeldiniz."); }
else
{sayaç += 1;
throw new Exception("Şifreniz hatalı!");
}
catch
(Exception hata)
{
MessageBox.Show(hata.Message);
}
finally
{
if (sayaç == 3)
{
MessageBox.Show("3 kere hata yaptınız, program
kapatılıyor.");
Application.Exit();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
SAYISAL LOTO PROGRAMI (PROFESYÖNEL)
(%49 ĐFADESĐ 1 ĐLE 49 ARASINDA SAYI VERĐLECEĞĐNĐ
GÖSTERĐYOR.)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
else if (varyok == 0)
{
label1.Text = "Đkisi aynı";
}
else { label1.Text = "Hayır içinde yok"; }
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;
namespace _9.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] dosyaadı =
Directory.GetFileSystemEntries("C:\\windows", "*.txt");
foreach (string eklenen in dosyaadı)
{
listBox1.Items.Add(eklenen);
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
}
namespace _10.hafta_dersi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
namespace _10.hafta_dersi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _11.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _11.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _11.hafta
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
namespace _12.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace _12.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void basla()
{
for (int i = 0; i <= 100; i++)
{
progressBar1.Value = i;
Thread.Sleep(30);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace _12.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void basla()
{
for (int i = 0; i <= 100; i++)
{
progressBar1.Value = i;
label1.Text = i.ToString();
Thread.Sleep(30);
}
}
void basla2()
{
for (int i = 0; i <= 100; i++)
{
progressBar2.Value = i;
label2.Text = i.ToString();
Thread.Sleep(60);
}
}
private void button1_Click(object sender, EventArgs e)
{
Thread kanal = new Thread(new ThreadStart(basla));
kanal.Start();
}
namespace _12.hafta_çalışma1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
richTextBox1.SaveFile(dosya_adi); }
}
}
}
namespace _12.hafta_çalışma1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
richTextBox1.SaveFile(dosya_adi); }
namespace _12.hafta_çalışma1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _12.hafta_çalışma1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
PĐCTUREBOX TANIMLAMA
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _13.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
RESĐM DÖNDÜRME
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _13.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
namespace _13.hafta_çalışma1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Çizim yaptırma
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
resim.DrawPolygon(kalem,noktalar);
resim.Dispose();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace _12.hafta_çalışma_2
{
public partial class Form1 : Form
{
public int x1;
public int y1;
bool cizim = false;
public int x2;
public int y2;
public Form1()
{
InitializeComponent();
resim.DrawPolygon(kalem,noktalar);
resim.Dispose();
resim.DrawString(textBox1.Text,new
Font("Arial",30,FontStyle.Bold,GraphicsUnit.Pixel), fırca, 40, 40);
x1 = e.X;
y1 = e.Y;
cizim = true;