private void BtnGoster_Click(object sender, EventArgs e) { int guno = int.Parse(txtGunNo.Text); Gunler gunAdi = (Gunler)guno - 1; txtGunNo.Text = ""; MessageBox.Show(gunAdi.ToString()); }
static void Main(string[] args) { Console.Title = "ENUM= NUMARALANDIRMA + SABİT".ToUpper(); Gunler gun = Gunler.cumartesi; switch (gun) { case Gunler.pazartesi: Console.WriteLine("Bugun tatil değil"); break; case Gunler.salı: Console.WriteLine("Bugun tatil değil"); break; case Gunler.çarşamba: Console.WriteLine("Bugun tatil değil"); break; case Gunler.perşembe: Console.WriteLine("Bugun tatil değil"); break; case Gunler.cuma: Console.WriteLine("Bugun tatil değil"); break; case Gunler.cumartesi: Console.WriteLine("Bugun tatil"); break; case Gunler.pazar: Console.WriteLine("Bugun tatil değil"); break; default: throw new ArgumentOutOfRangeException(); } Cinsiyet cns = Cinsiyet.Erkek; Console.WriteLine("cns:" + cns); Cinsiyet cns2 = (Cinsiyet)5;//var olanı yazar(Erkek) Console.WriteLine("cns2:" + cns2); Cinsiyet cns3 = (Cinsiyet)15;//15 yazar çünkü tanımlı değil Console.WriteLine("cns3:" + cns3); Console.ReadKey(); }
public string HesapDokumu(Gunler gun) { Console.WriteLine(gun.ToString() + " gününün dökümü"); return(""); }