SlideShare a Scribd company logo
http://www.enterprisecoding.com
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
Build ve
     Kod Yaz       Check in
                                        Test


       Fix
    edilebilir     Sebebini              Build     evet
Evet mi??           araştır     hayır başarılı mı?

           Hayır
    Tüm ekip
     bekler




                    Gated            Automate
     Kod Yaz
                   check-in           d build


                   Check-in’i
     Test için      kaydet
                                        Build       hayır
       hazır       (commit)     evet başarılı mı?
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
SP1

                        3.5

                        3.0

.Net 1.0   .Net 1.1   .Net 2.0   .Net 4.0

 2002       2003      2005-08     2010


CLR 1.0    CLR 1.1    CLR 2.0    CLR 4.0
public class Zaman {
    public double Saniye;
    public double Saat;
}


public class Zaman {
    public double Saniye;

      public double GetSaat(){
        return saniye/3600;
      }

      public void SetSaat(double value){
         saniye = value * 3600;
      }
}

...

Zaman zaman = new Zaman();
zaman.SetSaat(3);
public class Zaman {
    public double Saniye;
    public double Saat;
}


public class Zaman {
    public double Saniye;

      public double Saat{
        get{ return saniye/3600;}
        set{ saniye = value * 3600;}
      }
}

...

Zaman zaman = new Zaman();
zaman.Saat = 3;
public class Zaman {
    public double Saniye;
    public double Saat;
}


public class Zaman {
    public double Saniye;

      public double Saat{
        get{ return saniye/3600;}
      }
}

...

Zaman zaman = new Zaman();
zaman.Saat = 3;
public class Zaman {
    public double Saniye;
    public double Saat;
}


public class Zaman {
    public double Saniye;

    private double _saat;
    public double Saat {
      get { return _saat; }
      set { _saat = value; };
    }
}
public class Zaman {
    public double Saniye;

    private double _saat;
    public double Saat {
      get { return _saat; }
      set { _saat = value; };
    }
}


public class Zaman {
    public double Saniye;

    public double Saat { get; set; }
}
try {
     ...
}
catch (Exception ex){
     ...
}



try {
     ...
}
catch (Exception ex){
     ...
}
Finally {
     ...
}
try {
     File.OpenRead("Olmayanbir.dosya");
}
catch (Exception ex){
     Console.WriteLine("Dosya okunamadı");
}


try {
     File.OpenRead("Olmayanbir.dosya");
}
catch (FileNotFoundException fnex){
     Console.WriteLine("Dosya bulunamadı");
}
catch (Exception ex){
     Console.WriteLine("Beklenmeye bir hata oluştu");
}
public interface IInsan {
 string Adi { get; set; }
 int Yasi { get; set; }

 void Konus();
}


public class Erkek : IInsan {
 private string _adi
 public string Adi { get { return _adi; } set { _adi = value; } }

private int _yasi
public int Yasi { get { return _yasi; } set { _yas = value; } }

 public void Konus(){
   //...
 }
}
IInsan insan = new Erkek();
Console.WriteLine(insan.Adi);


insan = new Kadin();
Console.WriteLine(insan.Adi);


public class IOgrenci : IInsan {
  //...
}
public abstract class Sekil {
 public abstract void Ciz(int x, int y);
}


public class Kare: Sekil {
 public override void Ciz(int x, int y){
    //kare çizim kodu
 }
}


Sekil sekil = new Kare();

Console.WriteLine(sekil.Adi);
Sekil.Ciz(0, 0);
public abstract class Sekil {
 private string _adi;
 public string Adi {
   get { return _adi; }
 }

 public abstract void Ciz(int x, int y);
}

public class Kare: Sekil {
 public override void Ciz(int x, int y){
    //kare çizim kodu
 }
}
delegate tanımı                                         parametreler


            public delegate void Uyari(string mesaj);
            .
            .
                                                                         atama
            .
            Uyari uyari = delegate(string mesaj) {
                  MessageBox.Show(mesaj);
            };

            uyari("Hatalı değer girildi");
            .
            .                                                      kullanımı
            uyari("Lütfen yeniden deneyiniz");

            uyari = delegate{
                  MessageBox.Show("Hata oluştu");                       Alternatif
            };                                                         tanımlama

            uyari("kullanımayan parametre");
delegate tanımı                                                       event tanımı


public delegate void SurecDegistiIsleyici(int tamamlanmaOrani);
public event SurecDegistiIsleyici SurecDegisti;

islem.SurecDegisti += new SurecDegistiIsleyici(islem_SurecDegisti);

void islem_SurecDegisti(int tamamlanmaOrani) {                    Olay bildirimine
    .
    .
                                                                       kayıt
}


                                          Olay gerçekleştiğinde
                                          işletilecek süreç
Olay bildirimine
                                kayıt

islem.SurecDegisti += islem_SurecDegisti;
.
.
islem.SurecDegisti -= islem_SurecDegisti;


                            Olay bildirimine
                              kaydı silme
Özel temsilci
                                        (delegate)


private SurecDegistiIsleyici _surecDegistiIsleyici;
                                                       Olay bildirimine
public event SurecDegistiIsleyici SurecDegisti {            kayıt
   add { _surecDegistiIsleyici += value; }
   remove { _surecDegistiIsleyici -= value; }
}

                                    Olay bildirimine
                                      kaydı silme
Olay bildirimine kayıt
                                      olunduğuna emin olun



protected virtual void OnSurecDegistiIsleyici(int tamamlanmaOrani) {
   if (SurecDegistiIsleyici != null) {
      SurecDegistiIsleyici(tamamlanmaOrani);
   }
}


                                      Olay bildirimini tetikleyin
C#, Microsoft Yaz Okulu 2011 - İzmir
delegate
public class Ogrenci {
    public string Adi;
    public string Bolum;
}


List<Ogrenci> ogrenciler = new List<Ogrenci> {
    new Ogrenci{ Adi = "Duru", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." }
};

Bilgisayar mühendisi olan öğrencilerin listesi;
List<Ogrenci> bilMuhOgrencileri = new List<Ogrenci>();
foreach (Ogrenci ogrenci in ogrenciler) {
    if (ogrenci.Bolum == "Bil. Müh.") {
        bilMuhOgrencileri.Add(ogrenci);
    }
}
public class Ogrenci {
    public string Adi;
    public string Bolum;
}


List<Ogrenci> ogrenciler = new List<Ogrenci> {
    new Ogrenci{ Adi = "Duru", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." }
};


List<Ogrenci> bilMuhOgrencileri = ogrenciler.FindAll(
    delegate(Ogrenci ogrenci) {
        return ogrenci.Bolum == "Bil. Müh.";
    }
);
public class Ogrenci {
    public string Adi;
    public string Bolum;
}


List<Ogrenci> ogrenciler = new List<Ogrenci> {
    new Ogrenci{ Adi = "Duru", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." }
};


List<Ogrenci> bilMuhOgrencileri = ogrenciler.FindAll(ogrenci =>
ogrenci.Bolum == "Bil. Müh.");

List<Ogrenci> bilMuhOgrencileri = ogrenciler.FindAll((Ogrenci
ogrenci) => ogrenci.Bolum == "Bil. Müh.");
Lambda ifadeler
                                                 temsilcilere atanabilir

public delegate void Uyari(string mesaj);
.
.
.
Uyari uyari = mesaj => MessageBox.Show(mesaj);

uyari("Hatalı değer girildi");
.
.
uyari("Lütfen yeniden deneyiniz");
Lambda ifadeler yerel değişkenleri ve tanımlandıkları metod’a ait parametreleri
(dış değişkenleri) kullanabilirler;


public delegate void Uyari(string mesaj);
.
.
.
string varsayilanMesaj = "Hata Oluştu";
Uyari uyari = mesaj => MessageBox.Show(mesaj ?? varsayilanMesaj);

uyari("Hatalı değer girildi");
.
.
uyari(null);
Lambda ifadelerince kullanılan dış değişkenlerin değerleri lambda ifade
çağırıldığında hesaplanır;


int carpan = 3;
Func<int, int> carpim = x => x * carpan;

int sonuc1 = carpim(2); // sonuc1 = 6

carpan = 10;
int sonuc2 = carpim(2); // sonuc2 = 20


• Bir dış değişkenin değeri lambda ifade içerisinde değiştirilebilir
• Lambda ifade içerisinde tanımlanan değişkenler her çağırım için tekildirler
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
Genişletme metodunun string
                                              türü için olduğunu belirtir
 public static class StringEx {
    public static bool BosYadaBoslukMu(this string stringIfade) {
      return string.IsNullOrEmpty(stringIfade) ||
             stringIfade.Trim() == string.Empty;
    }
 }

Örnek kullanım;

string ornek = "Örnek";
Console.Write(ornek.BosYadaBoslukMu());

Derleyici taradından oluşturulan kod;

string ornek = "Örnek";
Console.Write(StringEx.BosYadaBoslukMu(ornek));
public static IEnumerable<int> To(this int ilk, int son)
{
        for (var l = ilk; l <= son; l++)
        {
                yield return l;
        }
}


foreach (int i in 5.To(15))
{
        j = i*i;
}
− new


        var
var ogrenci = new {Adi = "Fatih", Bolum = "Bil. Müh." }

Derleyici tarafından üretilen kod;
internal class OtomatikUretilmisTurAdi
{
   private string adi; //gercekte farkli bir ad verilebilir
   private int bolum; //gercekte farkli bir ad verilebilir

    public OtomatikUretilmisTurAdi (string adi, string bolum) {
       this.adi = adi;
       this.bolum = bolum;
    }

    public string Adi { get { return adi; } }
    public string Bolum { get { return bolum; } }
}


var ogrenci = new OtomatikUretilmisTurAdi("Fatih", "Bil. Müh.");
var ogrenci = new {Adi = "Fatih", Bolum = "Bil. Müh." }

string Adi = "Fatih";
string Bolum = "Bil. Müh.";

var ogrenci = new {Adi, Bolum };

string Adi = "Fatih";
string Bolum = "Bil. Müh.";

var ogrenci = new {Adi = Adi, Bolum = Bolum };
var ogrenci1 = new {Adi = "Fatih", Bolum = "Bil. Müh." };
var ogrenci2 = new {Adi = "Melis", Bolum = "Deri Müh." };

bool sonuc = ogrenci1.GetType() == ogrenci2.GetType(); //true
object nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}
object nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}

nesne = nesne + 1;


Yukarıdaki kodun derlenebilmesi için int türüne dönüşüm gerekli;
object nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}

nesne = (int)nesne + 1;
Aşağıdaki kod derleme zamanı hata vermese de çalışma zamanı hata oluşturur;
object nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}

nesne = (string)nesne + 1;
dynamic nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}



dynamic nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}

nesne = nesne + 1
Dinamik kullanılırken derleyici desteği olmayacağı için geliştirme zamanı kod
daha fazla hataya açıktır. Örneğin aşağıdaki kod derleme zamanı hata vermezken
çalışma zamanında hataya neden olacaktır;

dynamic nesne = 1;

if (nesne.GetType() == typeof(int)){
     Console.WriteLine("Tabiki türü int");
}

Nesne.VarolmayanBirMetod();
Bir önceki örneğin derlenmesi sonucu oluşan C# kodu;
internal class Program {
   private static void Main(string[] args) {
    object nesne = 1;
    if (<ma IN>o__SiteContainer0.<>p__Site1 == null) {
      <ma IN>o__SiteContainer0.<>p__Site1 = CallSite<func><calls ITE, object, bool>>.Create(
        Binder.UnaryOperation(CSharpBinderFlags.None,
         ExpressionType.IsTrue,
         typeof(Program),
         new CSharpArgumentInfo[] {
           CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
         }));
    }
    if (<ma IN>o__SiteContainer0.<>p__Site2 == null) {
      <ma IN>o__SiteContainer0.<>p__Site2 = CallSite<func><calls ITE, object, Type, object>>.Create(
        Binder.BinaryOperation(CSharpBinderFlags.None,
         ExpressionType.Equal,
         typeof(Program),
         new CSharpArgumentInfo[] {
           CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
           CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
         }));
    }
    if (<ma IN>o__SiteContainer0.<>p__Site3 == null) {
      <ma IN>o__SiteContainer0.<>p__Site3 = CallSite<func><calls ITE, object, object>>.Create(
        Binder.InvokeMember(CSharpBinderFlags.None,
         "GetType",
         null,
         typeof(Program),
         new CSharpArgumentInfo[] {
           CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
         }));
    }
    if (<ma IN>o__SiteContainer0.<>p__Site1.Target.Invoke(<ma IN>o__SiteContainer0.<>p__Site1,
         <ma IN>o__SiteContainer0.<>p__Site2.Target.Invoke(<ma IN>o__SiteContainer0.<>p__Site2,
           <ma IN>o__SiteContainer0.<>p__Site3.Target.Invoke(
             <ma IN>o__SiteContainer0.<>p__Site3, nesne),
             typeof(int)))) {
      Console.WriteLine("Tabi ki tx00fcrx00fc int");
    }
    else {
      Console.WriteLine("Tx00fcm makale hatalıymış :P");
    }

         if (<ma IN>o__SiteContainer0.<>p__Site4 == null) {
           <ma IN>o__SiteContainer0.<>p__Site4 = CallSite<func><calls ITE, object, object int,>>.Create(
              Binder.BinaryOperation(CSharpBinderFlags.None,
              ExpressionType.Add, typeof(Program),
              new CSharpArgumentInfo[] {
                 CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                 CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null)
               }));
         }
         nesne = <ma IN>o__SiteContainer0.<>p__Site4.Target.Invoke(<ma IN>o__SiteContainer0.<>p__Site4, nesne, 1);
     }

     [CompilerGenerated]
     private static class <ma IN>o__SiteContainer0 {
       public static CallSite<func><calls ITE, object, bool>> <>p__Site1;
       public static CallSite<func><calls ITE, object, Type, object>> <>p__Site2;
       public static CallSite<func><calls ITE, object, object>> <>p__Site3;
       public static CallSite<func><calls ITE, object, object int,>> <>p__Site4;
     }
 }
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
Sadece sınıflar için           Aynı sınıf üzerinde birden
   kullanılabilir                 fazla kullanılamaz



[AttributeUsage(
        AttributeTargets.Class,
        AllowMultiple = false,
        Inherited = false)]
    public class OrnekAttribute : Attribute { }




Alt sınıflarda tanımlı değil                          Bir öznitelik
                                                 tanımlandığını belirtir
public class Ogrenci {
     public string Adi;
     public string Bolum;
 }


FieldInfo[] ogrencialanlari = typeof(Ogrenci).GetFields(
                                             BindingFlags.Public |
                                             BindingFlags.Instance);

foreach (var ogrenciAlani in ogrencialanlari) {
    Console.WriteLine("Alan :" + ogrenciAlani.Name);
}


Çıktı;
 Alan : Adi
 Alan : Bolum
Ogrenci ogrenciInstance = new Ogrenci {
                                            Adi = "Fatih",
                                            Bolum = "Bil. Müh." };


Yukarıdaki ifadenin reflection karşılığı;


Type ogrenciType = Type.GetType("Ogrenci");

object ogrenciInstace = Activator.CreateInstance(ogrenciType);

FieldInfo adiAlani = ogrenciType.GetField("Adi");
FieldInfo bolumAlani = ogrenciType.GetField("Bolum");

adiAlani.SetValue(ogrenciInstace, "Fatih");
bolumAlani.SetValue(ogrenciInstace, "Bil. Müh.");
<?xml version="1.0" encoding="utf-8"?>
<Ogrenci xmlns="http://www.enterprisecoding.com"
         Adi="Fatih"
         Bolum="Bil. Müh." />



    Tür’ün tanımlı olacağı xml
                                             Xml tür adı
             isimuzayı


[XmlType(Namespace="http://www.enterprisecoding.com",TypeName="Ogrenci")]
public class Ogrenci {
    [XmlAttribute]
    public string Adi;             Veri elemanının xml içerisinde
                                   ne şekilde tutulacağını belirtir
      [XmlAttribute]
      public string Bolum;
}
Xml dokümanı giriş elemanı


[XmlRoot(Namespace="http://www.enterprisecoding.com",ElementName="Ogrenci
Listesi")]
public class OgrenciListesi {                 Xml içerisinde oluşturulacak
  [XmlArray(ElementName="Ogrenciler")]
                                                   array tanımlaması
  [XmlArrayItem(ElementName="Ogrenci")]
  public Ogrenci[] Ogrenciler;
}

                                    Xml içerisinde oluşturulacak array
                                       elemanlarının tanımlaması
Serileştirilecek tür

XmlSerializer serializer = new XmlSerializer(typeof(OgrenciListesi));

OgrenciListesi ogrenciListesi = new OgrenciListesi {
    Ogrenciler = new[] {
        new Ogrenci{ Adi = "Ali", Bolum = "Bil. Müh." },
        new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." },
        new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." }
    }
};

using (StreamWriter dosya = File.CreateText("ogrenciListesi.xml")) {
    serializer.Serialize(dosya, ogrenciListesi);
}


  Serileştirmenin yapılacağı
                                        Serileştirilecek nesne
            stream
<?xml version="1.0" encoding="utf-8"?>
<OgrenciListesi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns="http://www.enterprisecoding.com">
  <Ogrenciler>
    <Ogrenci Adi="Ali" Bolum="Bil. Müh." />
    <Ogrenci Adi="Fatih" Bolum="Bil. Müh." />
    <Ogrenci Adi="Melis" Bolum="Deri Müh." />
  </Ogrenciler>
</OgrenciListesi>
<?xml version="1.0" encoding="utf-8"?>
<OgrenciListesi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns="http://www.enterprisecoding.com">
  <Ogrenciler>
    <Ogrenci Adi="Ali" Bolum="Bil. Müh." />
    <Ogrenci Adi="Fatih" Bolum="Bil. Müh." />
    <Ogrenci Adi="Melis" Bolum="Deri Müh." />
  </Ogrenciler>
</OgrenciListesi>
XmlSerializer serializer = new XmlSerializer(typeof(OgrenciListesi));

using (StreamReader dosya = File.OpenText("ogrenciListesi.xml")) {
 var ogrenciListesi=(OgrenciListesi)serializer.Deserialize(dosya);
    .
    .
    .
}
public class Ogrenci {
    public string Adi;
    public string Bolum;
}


List<Ogrenci> ogrenciler = new List<Ogrenci> {
    new Ogrenci{ Adi = "Ali", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." },
    new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." }
};


var bilMuhOgrencileri = ogrenciler.Where(ogrenci => ogrenci.Bolum ==
"Bil. Müh.");
Aynı sorgunun farklı bir şekilde ifadesi;

var bilMuhOgrencileri = from ogrenci in ogrenciler
                        where ogrenci.Bolum == "Bil. Müh."
                        select ogrenci;




Sadece öğrencilerin adını sorgulamak için;

 var bilMuhOgrencileri = from ogrenci in ogrenciler
                         where ogrenci.Bolum == "Bil. Müh."
                         select ogrenci.Adi;
Aynı sorgu, isimler sıralı şekilde;

 var bilMuhOgrencileri = from ogrenci in ogrenciler
                         where ogrenci.Bolum == "Bil. Müh."
                         orderby ogrenci.Adi ascending
                         select ogrenci;

                     Sorgu Sözdizimi
          (Query Syntax/Query Expression Syntax)

Başka bir ifade ile;

 var bilMuhOgrencileri = ogrenciler
                         .Where(ogrenci => ogrenci.Bolum == "Bil. Müh.")
                         .OrderBy(ogrenci => ogrenci.Adi)
                         .Select(ogrenci => ogrenci);

                                                         Akıcı Sözdizimi
                                                         (Fluent Syntax)
Bir önceki örnekteki akıcı sözdizimini incelersek;

var bilMuhOgrencileri = ogrenciler
                        .Where(ogrenci => ogrenci.Bolum == "Bil. Müh.")
                        .OrderBy(ogrenci => ogrenci.Adi)
                        .Select(ogrenci => ogrenci);




var filtrelenmis = ogrenciler.Where(ogrenci=>ogrenci.Bolum=="Bil. Müh.");
var siralanmıs   = filtrelenmis.OrderBy(ogrenci => ogrenci.Adi);
var sorgu        = siralanmıs.Select(ogrenci => ogrenci);
Dış değişken kullanırken dikkati elden bırakmamalı;

int[] sayilar = { 9, 2, 0, 8, 6, 7, 5, 4, 1, 3 };

int limit = 5;
var sorgu = from sayi in sayilar
            where sayi > limit
            select sayi;

int[] limitUstuSayilara1 = sorgu.ToArray(); // 9, 8, 6, 7

limit = 3;
int[] limitUstuSayilara2 = sorgu.ToArray(); // 9, 8, 6, 7, 5, 4
static void Main(string[] args) {
    Thread t = new Thread(EkranaYaz);
    t.Start();

      for (int i = 0; i < 999; i++) {
          Console.Write("-");
      }
}

private static void EkranaYaz() {
    for (int i = 0; i < 999; i++) {
        Console.Write("*");
    }
}

Program çıktısı;
--------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
*****************************************************************************************
***********************************************-------------------------------------------------------------
---------------------------------------------------------------------------
static void Main(string[] args) {
    Thread t = new Thread(EkranaYaz);
    t.Start();

    for (int i = 0; i < 999; i++) {     Başlatılan thread’in
        Console.Write("-");              bitmesi beklenir
    }

    t.Join();
}

private static void EkranaYaz() {
    for (int i = 0; i < 999; i++) {
        Console.Write("*");
    }
}
public delegate void ThreadStart();
public delegate void ParameterizedThreadStart (object obj);

static void Main(string[] args) {
    Thread t = new Thread(EkranaYaz);
    t.Start("*");

    for (int i = 0; i < 999; i++) {
        Console.Write("-");
    }

    t.Join();
}

private static void EkranaYaz(object mesaj) {
    for (int i = 0; i < 999; i++) {
        Console.Write(mesaj as string);
    }
}
C#, Microsoft Yaz Okulu 2011 - İzmir
Bildirimsel




Eşzamanlılık            Dinamik
2002 - C# 1.0
                Managed Kod
2005 - C# 2.0
                       Generics

2002 - C# 1.0
                    Managed Kod
public static IEnumerable<int> To(this int ilk, int son)
{
        for (var l = ilk; l <= son; l++)
        {
                yield return l;
        }
}


foreach (int i in 5.To(15))
{
        j = i*i;
}
2007 - C# 3.0
                              LINQ

    2005 - C# 2.0
                          Generics

2002 - C# 1.0
                     Managed Kod
List<int> ogrenciIdleri = new List<int>();
foreach (Ogrenci ogrenci in ogrenciler)
{
        if (ogrenci.BolumID == 1)
        {
                ogrenciIdleri.Add(ogrenci.ID);
        }
}


var ogrenciIdleri = ogrenciler
                         .Where(ogrenci => ogrenci.BolumID == 1)
                         .Select(ogrenci => ogrenci.ID);


var ogrenciIdleri = from ogrenci in ogrenciler
                  where ogrenci.BolumID == 1
                  select ogrenci.ID;
2010 - C# 4.0
                                       Dinamik programlama

          2007 - C# 3.0
                                LINQ

    2005 - C# 2.0
                          Generics

2002 - C# 1.0
                     Managed Kod
object hesapMakinesi = HesapMakinesiniGetir();
Type hesapMakinesiTuru = hesapMakinesi.GetType();
object sonuc = hesapMakinesiTuru.InvokeMember("Ekle",
BindingFlags.InvokeMethod,
              null, hesapMakinesi, new object[] { 1, 2});
int toplam = Convert.ToInt32(sonuc);



dynamic hesapMakinesi = HesapMakinesiniGetir();
int toplam = hesapMakinesi.Add(1, 2);
Bildirimsel
            C# 3.0




                        Dinamik
Eşzamanlılık
                         C# 4
C#, Microsoft Yaz Okulu 2011 - İzmir
... - C# v.Next
                                          Asenkron Programlama

                2010 - C# 4.0
                                       Dinamik programlama

          2007 - C# 3.0
                                LINQ

    2005 - C# 2.0
                          Generics

2002 - C# 1.0
                     Managed Kod
C#, Microsoft Yaz Okulu 2011 - İzmir
var veri = VeriyiIndir(...);
VeriyiIsle(veri);




VeriyiIndirAsync(... , veri => {
    VeriyiIsle(veri);
});
C#, Microsoft Yaz Okulu 2011 - İzmir
public TResult VeriyiIndir(TParam parametre);

…

public IAsyncResult BeginVeriyiIndir
    (TParam parametre, AsyncCallback geriCagri, object durum);

public TResult EndVeriyiIndir (IAsyncResult asenkronSonuc);
public TResult VeriyiIndir(TParam parametre);
…
public void VeriyiIndirAsync(TParam parametre);
public event VeriIndirTamamlandiEventHandler
VeriIndirTamamlandi;

public delegate void VeriIndirTamamlandiEventHandler(
    object sender, VeriIndirTamamlandiEventArgs eventArgs);

public class VeriIndirTamamlandiEventArgs :
AsyncCompletedEventArgs
{
    public TResult Sonuc { get; }
}
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
private void adresleriBul_Click(object sender, EventArgs e) {
    <adresleriBul_Click>d__0 d__ = new <adresleriBul_Click>d__0(0);
     d__.<>4__this = this;
     d__.sender = sender;
     d__.e = e;
     d__.MoveNextDelegate = new Action(d__.MoveNext);
     d__.$builder = VoidAsyncMethodBuilder.Create();
     d__.MoveNext();
}
[CompilerGenerated]
private sealed class <adresleriBul_Click>d__0 {
   private bool $__disposing;
   private bool $__doFinallyBodies;
   public VoidAsyncMethodBuilder $builder;
   private int <>1__state;
   public EventArgs <>3__e;
   public object <>3__sender;
   public AnaEkran <>4__this;
   private string <1>t__$await5;
   private TaskAwaiter<string> <a1>t__$await6;
   public string <adress>5__1;
   public Match <eslesim>5__4;
   public MatchCollection <eslesimler>5__3;
   public string <icerik>5__2;
   public EventArgs e;
   public Action MoveNextDelegate;
   public object sender;

    [DebuggerHidden]
    public <adresleriBul_Click>d__0(int <>1__state) {
      this.<>1__state = <>1__state;
    }

    [DebuggerHidden]
    public void Dispose() {
      this.$__disposing = true;
      this.MoveNext();
      this.<>1__state = -1;
    }

    public void MoveNext() {
      try {
         this.$__doFinallyBodies = true;
         if (this.<>1__state != 1) {
             if (this.<>1__state == -1) {
                 return;
             }

              this.<adress>5__1 = "http://www.enterprisecoding.com/blog/";
              this.<a1>t__$await6 = new WebClient().DownloadStringTaskAsync(this.<adress>5__1).GetAwaiter<string>();
              this.<>1__state = 1;
              this.$__doFinallyBodies = false;
              if (this.<a1>t__$await6.BeginAwait(this.MoveNextDelegate)) {
                  return;
              }
              this.$__doFinallyBodies = true;
          }

          this.<>1__state = 0;
          this.<1>t__$await5 = this.<a1>t__$await6.EndAwait();
          this.<icerik>5__2 = this.<1>t__$await5;
          this.<eslesimler>5__3 = Regex.Matches(this.<icerik>5__2,
                              @"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-@/$,]*",
                              RegexOptions.IgnoreCase);
          IEnumerator CS$5$0002 = this.<eslesimler>5__3.GetEnumerator();
          try {
             while (CS$5$0002.MoveNext()) {
                 this.<eslesim>5__4 = (Match) CS$5$0002.Current;
                 this.<>4__this.adresListesi.Items.Add(this.<eslesim>5__4.Value);
             }
          }
          finally {
             if (this.$__doFinallyBodies) {
                 IDisposable CS$0$0003 = CS$5$0002 as IDisposable;
                 if (CS$0$0003 != null) {
                     CS$0$0003.Dispose();
                 }
             }
          }
          this.<>1__state = -1;
          this.$builder.SetCompleted();
        }
        catch (Exception) {
          this.<>1__state = -1;
          this.$builder.SetCompleted();
          throw;
        }
    }
}
C#, Microsoft Yaz Okulu 2011 - İzmir
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }




                  
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }




                  
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }




                                  
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }




                                  
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }

                



                                  
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }

                 



                                                        
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }

                



                                                        
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }

                 



                                                        
async void DoWorkAsync() {
    var t1 = ProcessFeedAsync("www.acme.com/rss");
    var t2 = ProcessFeedAsync("www.xyznews.com/rss");
    await Task.WhenAll(t1, t2);
    DisplayMessage("Done");
}                               async Task ProcessFeedAsync(string url) {
                                    var text = await DownloadFeedAsync(url);
                                    var doc = ParseFeedIntoDoc(text);
                                    await SaveDocAsync(doc);
                                    ProcessLog.WriteEntry(url);
                                }

                 



                                                        
private void adresleriBul_Click(object sender, EventArgs e) {
   var adress = "http://www.enterprisecoding.com/blog/";
   var icerik = new WebClient().DownloadString(adress);
   var eslesimler = Regex.Matches(icerik,
@"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-
@/$,]*", RegexOptions.IgnoreCase);

     foreach (Match eslesim in eslesimler) {
       adresListesi.Items.Add(eslesim.Value);
    }
}
delegate void EslesimleriEkleCallback(MatchCollection eslesimler);

private void adresleriBul_Click(object sender, EventArgs e) {
   var islem = new Thread(new ThreadStart(AdressleriBul));
   islem.Start();
}

private void AdressleriBul() {
   var adress = "http://www.enterprisecoding.com/blog/";
   var icerik = new WebClient().DownloadString(adress);
   var eslesimler = Regex.Matches(icerik,
       @"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-@/$,]*",
       RegexOptions.IgnoreCase);

    if (adresListesi.InvokeRequired) {//Fonksiyon ayrı thread’den çağırılmış
         var callback = new EslesimleriEkleCallback(EslesimleriEkle);
         Invoke(callback, new[] { eslesimler });
    } else { //Aynı thread, doğrudan çağırılabilir
         EslesimleriEkle(eslesimler);
    }
}

private void EslesimleriEkle(MatchCollection eslesimler) {
    foreach (Match eslesim in eslesimler) {
         adresListesi.Items.Add(eslesim.Value);
    }
}
private async void adresleriBul_Click(object sender, EventArgs e) {
   var adress = "http://www.enterprisecoding.com/blog/";
   var icerik = await new WebClient().DownloadStringTaskAsync(adress);
   var eslesimler = Regex.Matches(icerik,
@"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-@/$,]*",
RegexOptions.IgnoreCase);

     foreach (Match eslesim in eslesimler) {
       adresListesi.Items.Add(eslesim.Value);
    }
}
... - C# v.Next Next
                                                CaaS

                    ... - C# v.Next
                                            Asenkron Programlama

                2010 - C# 4.0
                                       Dinamik programlama

          2007 - C# 3.0
                                LINQ

    2005 - C# 2.0
                          Generics

2002 - C# 1.0
                     Managed Kod
Sınıf
Meta-programlama                                   Oku-Çalıştır-Yaz
                    public               Foo          Döngüsü
 Dil Nesne Modeli               alan


                    private                    X

                                string




                                                           .NET
 Kaynak Kodu
  Source code                                            Assembly
                                                         Source code
   Source code         Compiler
                       Derleyici                          Source code
C#, Microsoft Yaz Okulu 2011 - İzmir
C#, Microsoft Yaz Okulu 2011 - İzmir
3D Derinlik Algılayıcıları

                 RGB Kamera




Çoklu Mikrofon Dizisi      Hareket Motoru
C#, Microsoft Yaz Okulu 2011 - İzmir
ShoulderRight                         ShoulderLeft

     ElbowRight                        Head                    ElbowLeft

  WristRight                                                           WristLeft


HandRight                                                              HandLeft




                                                 ShoulderCenter
                    Spine
                                              HipCenter

                            HipRight             HipLeft




                   KneeRight                        KneeLeft


      AnkleRight                                           AnkleLeft

        FootLeft                                                   FootLeft
http://www.enterprisecoding.com

More Related Content

DOC
10. istisna isleme
DOC
11. stl kütüphanesi
DOC
9. şablonlar
DOC
5. kurucu, yok edici ve kopyalama fonksiyonları
DOC
8. çok biçimlilik
PDF
Java ile grogramlamaya giris
DOCX
4. yapılar
PDF
Ileri seviye javascript by Azer Koculu
10. istisna isleme
11. stl kütüphanesi
9. şablonlar
5. kurucu, yok edici ve kopyalama fonksiyonları
8. çok biçimlilik
Java ile grogramlamaya giris
4. yapılar
Ileri seviye javascript by Azer Koculu

Viewers also liked (20)

PPTX
Masaüstü uygulamasından Asp.Net sayfalarıyla etkileşim
PDF
Windows Azure Platform Başlarken
PDF
Windows Azure ile Cloud Computing Uygulamaları - 2
PDF
Windows Azure ile Cloud Computing Uygulamaları - 5
PDF
Windows Azure ile Cloud Computing Uygulamaları - 6
PDF
Cloud computing Düşüncesi
PDF
Windows Azure ile Cloud Computing Uygulamaları
PDF
Windows Azure ile Cloud Computing Uygulamaları - 1
PDF
Enterprise Library 5 - Data Access Application Block
PDF
JavaScript ile Taş Kırmak
PDF
ASP.NET MVC 3 RC Sürümüne Bakış
PDF
ASP.Net MVC 4 'e Giriş
PDF
jQuery ve Mobil Web Uygulamaları
PDF
jQuery ile ASP.NET Uygulamaları Geliştirme
PDF
ASP.Net MVC 4 ile Web Uygulaması Geliştirmek
PDF
Yazılımcılar için iis 7 ve IIS 7.5 yenilikleri ve kolaylıkları
PDF
ASP.Net MVC ile Web Uygulamaları -14(Spark ViewEngine)
PDF
ASP.Net MVC ile Web Uygulamaları -15(Layout ve View)
PDF
Windows Azure ile Uygulama Geliştirme Senaryoları
PDF
ASP.Net MVC ile Web Uygulamaları -16(JQuery)
Masaüstü uygulamasından Asp.Net sayfalarıyla etkileşim
Windows Azure Platform Başlarken
Windows Azure ile Cloud Computing Uygulamaları - 2
Windows Azure ile Cloud Computing Uygulamaları - 5
Windows Azure ile Cloud Computing Uygulamaları - 6
Cloud computing Düşüncesi
Windows Azure ile Cloud Computing Uygulamaları
Windows Azure ile Cloud Computing Uygulamaları - 1
Enterprise Library 5 - Data Access Application Block
JavaScript ile Taş Kırmak
ASP.NET MVC 3 RC Sürümüne Bakış
ASP.Net MVC 4 'e Giriş
jQuery ve Mobil Web Uygulamaları
jQuery ile ASP.NET Uygulamaları Geliştirme
ASP.Net MVC 4 ile Web Uygulaması Geliştirmek
Yazılımcılar için iis 7 ve IIS 7.5 yenilikleri ve kolaylıkları
ASP.Net MVC ile Web Uygulamaları -14(Spark ViewEngine)
ASP.Net MVC ile Web Uygulamaları -15(Layout ve View)
Windows Azure ile Uygulama Geliştirme Senaryoları
ASP.Net MVC ile Web Uygulamaları -16(JQuery)
Ad

Similar to C#, Microsoft Yaz Okulu 2011 - İzmir (20)

PPTX
C#, Microsoft Yaz Okulu 2010 - İzmir
PDF
Nurdan sarıkaya
PPT
başlıkk 11111
PPTX
Net ve i̇stisnalar
PDF
Eclipse ile Java Debug
PPTX
23.10.2014 C# & .Net giriş
PPTX
CSharp Programlama Dili ve Net Framework
PDF
Nesne tabanlı programlamada metotlar
PPTX
C# Metotlar/Fonksiyonlar
PDF
C# programlama dili
PPTX
Karar kontrol deyi̇mleri̇
PPTX
Karar kontrol deyi̇mleri̇
PPTX
Temiz Kod
PPTX
Delphi xe5
PPTX
Delphi xe5
PDF
Visual Basic.NET Kodlama Standartları 1.0
PDF
Ti ks vb v1.0
PPTX
24.10.2014 .net c# giriş
PPT
007 Uml Modelleri Analiz Ve Tasarim [74 Slides]
PPTX
Oop’nin temel ilkeleri
C#, Microsoft Yaz Okulu 2010 - İzmir
Nurdan sarıkaya
başlıkk 11111
Net ve i̇stisnalar
Eclipse ile Java Debug
23.10.2014 C# & .Net giriş
CSharp Programlama Dili ve Net Framework
Nesne tabanlı programlamada metotlar
C# Metotlar/Fonksiyonlar
C# programlama dili
Karar kontrol deyi̇mleri̇
Karar kontrol deyi̇mleri̇
Temiz Kod
Delphi xe5
Delphi xe5
Visual Basic.NET Kodlama Standartları 1.0
Ti ks vb v1.0
24.10.2014 .net c# giriş
007 Uml Modelleri Analiz Ve Tasarim [74 Slides]
Oop’nin temel ilkeleri
Ad

C#, Microsoft Yaz Okulu 2011 - İzmir

  • 7. Build ve Kod Yaz Check in Test Fix edilebilir Sebebini Build evet Evet mi?? araştır hayır başarılı mı? Hayır Tüm ekip bekler Gated Automate Kod Yaz check-in d build Check-in’i Test için kaydet Build hayır hazır (commit) evet başarılı mı?
  • 10. SP1 3.5 3.0 .Net 1.0 .Net 1.1 .Net 2.0 .Net 4.0 2002 2003 2005-08 2010 CLR 1.0 CLR 1.1 CLR 2.0 CLR 4.0
  • 11. public class Zaman { public double Saniye; public double Saat; } public class Zaman { public double Saniye; public double GetSaat(){ return saniye/3600; } public void SetSaat(double value){ saniye = value * 3600; } } ... Zaman zaman = new Zaman(); zaman.SetSaat(3);
  • 12. public class Zaman { public double Saniye; public double Saat; } public class Zaman { public double Saniye; public double Saat{ get{ return saniye/3600;} set{ saniye = value * 3600;} } } ... Zaman zaman = new Zaman(); zaman.Saat = 3;
  • 13. public class Zaman { public double Saniye; public double Saat; } public class Zaman { public double Saniye; public double Saat{ get{ return saniye/3600;} } } ... Zaman zaman = new Zaman(); zaman.Saat = 3;
  • 14. public class Zaman { public double Saniye; public double Saat; } public class Zaman { public double Saniye; private double _saat; public double Saat { get { return _saat; } set { _saat = value; }; } }
  • 15. public class Zaman { public double Saniye; private double _saat; public double Saat { get { return _saat; } set { _saat = value; }; } } public class Zaman { public double Saniye; public double Saat { get; set; } }
  • 16. try { ... } catch (Exception ex){ ... } try { ... } catch (Exception ex){ ... } Finally { ... }
  • 17. try { File.OpenRead("Olmayanbir.dosya"); } catch (Exception ex){ Console.WriteLine("Dosya okunamadı"); } try { File.OpenRead("Olmayanbir.dosya"); } catch (FileNotFoundException fnex){ Console.WriteLine("Dosya bulunamadı"); } catch (Exception ex){ Console.WriteLine("Beklenmeye bir hata oluştu"); }
  • 18. public interface IInsan { string Adi { get; set; } int Yasi { get; set; } void Konus(); } public class Erkek : IInsan { private string _adi public string Adi { get { return _adi; } set { _adi = value; } } private int _yasi public int Yasi { get { return _yasi; } set { _yas = value; } } public void Konus(){ //... } }
  • 19. IInsan insan = new Erkek(); Console.WriteLine(insan.Adi); insan = new Kadin(); Console.WriteLine(insan.Adi); public class IOgrenci : IInsan { //... }
  • 20. public abstract class Sekil { public abstract void Ciz(int x, int y); } public class Kare: Sekil { public override void Ciz(int x, int y){ //kare çizim kodu } } Sekil sekil = new Kare(); Console.WriteLine(sekil.Adi); Sekil.Ciz(0, 0);
  • 21. public abstract class Sekil { private string _adi; public string Adi { get { return _adi; } } public abstract void Ciz(int x, int y); } public class Kare: Sekil { public override void Ciz(int x, int y){ //kare çizim kodu } }
  • 22. delegate tanımı parametreler public delegate void Uyari(string mesaj); . . atama . Uyari uyari = delegate(string mesaj) { MessageBox.Show(mesaj); }; uyari("Hatalı değer girildi"); . . kullanımı uyari("Lütfen yeniden deneyiniz"); uyari = delegate{ MessageBox.Show("Hata oluştu"); Alternatif }; tanımlama uyari("kullanımayan parametre");
  • 23. delegate tanımı event tanımı public delegate void SurecDegistiIsleyici(int tamamlanmaOrani); public event SurecDegistiIsleyici SurecDegisti; islem.SurecDegisti += new SurecDegistiIsleyici(islem_SurecDegisti); void islem_SurecDegisti(int tamamlanmaOrani) { Olay bildirimine . . kayıt } Olay gerçekleştiğinde işletilecek süreç
  • 24. Olay bildirimine kayıt islem.SurecDegisti += islem_SurecDegisti; . . islem.SurecDegisti -= islem_SurecDegisti; Olay bildirimine kaydı silme
  • 25. Özel temsilci (delegate) private SurecDegistiIsleyici _surecDegistiIsleyici; Olay bildirimine public event SurecDegistiIsleyici SurecDegisti { kayıt add { _surecDegistiIsleyici += value; } remove { _surecDegistiIsleyici -= value; } } Olay bildirimine kaydı silme
  • 26. Olay bildirimine kayıt olunduğuna emin olun protected virtual void OnSurecDegistiIsleyici(int tamamlanmaOrani) { if (SurecDegistiIsleyici != null) { SurecDegistiIsleyici(tamamlanmaOrani); } } Olay bildirimini tetikleyin
  • 29. public class Ogrenci { public string Adi; public string Bolum; } List<Ogrenci> ogrenciler = new List<Ogrenci> { new Ogrenci{ Adi = "Duru", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." } }; Bilgisayar mühendisi olan öğrencilerin listesi; List<Ogrenci> bilMuhOgrencileri = new List<Ogrenci>(); foreach (Ogrenci ogrenci in ogrenciler) { if (ogrenci.Bolum == "Bil. Müh.") { bilMuhOgrencileri.Add(ogrenci); } }
  • 30. public class Ogrenci { public string Adi; public string Bolum; } List<Ogrenci> ogrenciler = new List<Ogrenci> { new Ogrenci{ Adi = "Duru", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." } }; List<Ogrenci> bilMuhOgrencileri = ogrenciler.FindAll( delegate(Ogrenci ogrenci) { return ogrenci.Bolum == "Bil. Müh."; } );
  • 31. public class Ogrenci { public string Adi; public string Bolum; } List<Ogrenci> ogrenciler = new List<Ogrenci> { new Ogrenci{ Adi = "Duru", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." } }; List<Ogrenci> bilMuhOgrencileri = ogrenciler.FindAll(ogrenci => ogrenci.Bolum == "Bil. Müh."); List<Ogrenci> bilMuhOgrencileri = ogrenciler.FindAll((Ogrenci ogrenci) => ogrenci.Bolum == "Bil. Müh.");
  • 32. Lambda ifadeler temsilcilere atanabilir public delegate void Uyari(string mesaj); . . . Uyari uyari = mesaj => MessageBox.Show(mesaj); uyari("Hatalı değer girildi"); . . uyari("Lütfen yeniden deneyiniz");
  • 33. Lambda ifadeler yerel değişkenleri ve tanımlandıkları metod’a ait parametreleri (dış değişkenleri) kullanabilirler; public delegate void Uyari(string mesaj); . . . string varsayilanMesaj = "Hata Oluştu"; Uyari uyari = mesaj => MessageBox.Show(mesaj ?? varsayilanMesaj); uyari("Hatalı değer girildi"); . . uyari(null);
  • 34. Lambda ifadelerince kullanılan dış değişkenlerin değerleri lambda ifade çağırıldığında hesaplanır; int carpan = 3; Func<int, int> carpim = x => x * carpan; int sonuc1 = carpim(2); // sonuc1 = 6 carpan = 10; int sonuc2 = carpim(2); // sonuc2 = 20 • Bir dış değişkenin değeri lambda ifade içerisinde değiştirilebilir • Lambda ifade içerisinde tanımlanan değişkenler her çağırım için tekildirler
  • 37. Genişletme metodunun string türü için olduğunu belirtir public static class StringEx { public static bool BosYadaBoslukMu(this string stringIfade) { return string.IsNullOrEmpty(stringIfade) || stringIfade.Trim() == string.Empty; } } Örnek kullanım; string ornek = "Örnek"; Console.Write(ornek.BosYadaBoslukMu()); Derleyici taradından oluşturulan kod; string ornek = "Örnek"; Console.Write(StringEx.BosYadaBoslukMu(ornek));
  • 38. public static IEnumerable<int> To(this int ilk, int son) { for (var l = ilk; l <= son; l++) { yield return l; } } foreach (int i in 5.To(15)) { j = i*i; }
  • 39. − new var
  • 40. var ogrenci = new {Adi = "Fatih", Bolum = "Bil. Müh." } Derleyici tarafından üretilen kod; internal class OtomatikUretilmisTurAdi { private string adi; //gercekte farkli bir ad verilebilir private int bolum; //gercekte farkli bir ad verilebilir public OtomatikUretilmisTurAdi (string adi, string bolum) { this.adi = adi; this.bolum = bolum; } public string Adi { get { return adi; } } public string Bolum { get { return bolum; } } } var ogrenci = new OtomatikUretilmisTurAdi("Fatih", "Bil. Müh.");
  • 41. var ogrenci = new {Adi = "Fatih", Bolum = "Bil. Müh." } string Adi = "Fatih"; string Bolum = "Bil. Müh."; var ogrenci = new {Adi, Bolum }; string Adi = "Fatih"; string Bolum = "Bil. Müh."; var ogrenci = new {Adi = Adi, Bolum = Bolum };
  • 42. var ogrenci1 = new {Adi = "Fatih", Bolum = "Bil. Müh." }; var ogrenci2 = new {Adi = "Melis", Bolum = "Deri Müh." }; bool sonuc = ogrenci1.GetType() == ogrenci2.GetType(); //true
  • 43. object nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); }
  • 44. object nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); } nesne = nesne + 1; Yukarıdaki kodun derlenebilmesi için int türüne dönüşüm gerekli; object nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); } nesne = (int)nesne + 1;
  • 45. Aşağıdaki kod derleme zamanı hata vermese de çalışma zamanı hata oluşturur; object nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); } nesne = (string)nesne + 1;
  • 46. dynamic nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); } dynamic nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); } nesne = nesne + 1
  • 47. Dinamik kullanılırken derleyici desteği olmayacağı için geliştirme zamanı kod daha fazla hataya açıktır. Örneğin aşağıdaki kod derleme zamanı hata vermezken çalışma zamanında hataya neden olacaktır; dynamic nesne = 1; if (nesne.GetType() == typeof(int)){ Console.WriteLine("Tabiki türü int"); } Nesne.VarolmayanBirMetod();
  • 48. Bir önceki örneğin derlenmesi sonucu oluşan C# kodu; internal class Program { private static void Main(string[] args) { object nesne = 1; if (<ma IN>o__SiteContainer0.<>p__Site1 == null) { <ma IN>o__SiteContainer0.<>p__Site1 = CallSite<func><calls ITE, object, bool>>.Create( Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(Program), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })); } if (<ma IN>o__SiteContainer0.<>p__Site2 == null) { <ma IN>o__SiteContainer0.<>p__Site2 = CallSite<func><calls ITE, object, Type, object>>.Create( Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Equal, typeof(Program), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null) })); } if (<ma IN>o__SiteContainer0.<>p__Site3 == null) { <ma IN>o__SiteContainer0.<>p__Site3 = CallSite<func><calls ITE, object, object>>.Create( Binder.InvokeMember(CSharpBinderFlags.None, "GetType", null, typeof(Program), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })); } if (<ma IN>o__SiteContainer0.<>p__Site1.Target.Invoke(<ma IN>o__SiteContainer0.<>p__Site1, <ma IN>o__SiteContainer0.<>p__Site2.Target.Invoke(<ma IN>o__SiteContainer0.<>p__Site2, <ma IN>o__SiteContainer0.<>p__Site3.Target.Invoke( <ma IN>o__SiteContainer0.<>p__Site3, nesne), typeof(int)))) { Console.WriteLine("Tabi ki tx00fcrx00fc int"); } else { Console.WriteLine("Tx00fcm makale hatalıymış :P"); } if (<ma IN>o__SiteContainer0.<>p__Site4 == null) { <ma IN>o__SiteContainer0.<>p__Site4 = CallSite<func><calls ITE, object, object int,>>.Create( Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Add, typeof(Program), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) })); } nesne = <ma IN>o__SiteContainer0.<>p__Site4.Target.Invoke(<ma IN>o__SiteContainer0.<>p__Site4, nesne, 1); } [CompilerGenerated] private static class <ma IN>o__SiteContainer0 { public static CallSite<func><calls ITE, object, bool>> <>p__Site1; public static CallSite<func><calls ITE, object, Type, object>> <>p__Site2; public static CallSite<func><calls ITE, object, object>> <>p__Site3; public static CallSite<func><calls ITE, object, object int,>> <>p__Site4; } }
  • 52. Sadece sınıflar için Aynı sınıf üzerinde birden kullanılabilir fazla kullanılamaz [AttributeUsage( AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public class OrnekAttribute : Attribute { } Alt sınıflarda tanımlı değil Bir öznitelik tanımlandığını belirtir
  • 53. public class Ogrenci { public string Adi; public string Bolum; } FieldInfo[] ogrencialanlari = typeof(Ogrenci).GetFields( BindingFlags.Public | BindingFlags.Instance); foreach (var ogrenciAlani in ogrencialanlari) { Console.WriteLine("Alan :" + ogrenciAlani.Name); } Çıktı; Alan : Adi Alan : Bolum
  • 54. Ogrenci ogrenciInstance = new Ogrenci { Adi = "Fatih", Bolum = "Bil. Müh." }; Yukarıdaki ifadenin reflection karşılığı; Type ogrenciType = Type.GetType("Ogrenci"); object ogrenciInstace = Activator.CreateInstance(ogrenciType); FieldInfo adiAlani = ogrenciType.GetField("Adi"); FieldInfo bolumAlani = ogrenciType.GetField("Bolum"); adiAlani.SetValue(ogrenciInstace, "Fatih"); bolumAlani.SetValue(ogrenciInstace, "Bil. Müh.");
  • 55. <?xml version="1.0" encoding="utf-8"?> <Ogrenci xmlns="http://www.enterprisecoding.com" Adi="Fatih" Bolum="Bil. Müh." /> Tür’ün tanımlı olacağı xml Xml tür adı isimuzayı [XmlType(Namespace="http://www.enterprisecoding.com",TypeName="Ogrenci")] public class Ogrenci { [XmlAttribute] public string Adi; Veri elemanının xml içerisinde ne şekilde tutulacağını belirtir [XmlAttribute] public string Bolum; }
  • 56. Xml dokümanı giriş elemanı [XmlRoot(Namespace="http://www.enterprisecoding.com",ElementName="Ogrenci Listesi")] public class OgrenciListesi { Xml içerisinde oluşturulacak [XmlArray(ElementName="Ogrenciler")] array tanımlaması [XmlArrayItem(ElementName="Ogrenci")] public Ogrenci[] Ogrenciler; } Xml içerisinde oluşturulacak array elemanlarının tanımlaması
  • 57. Serileştirilecek tür XmlSerializer serializer = new XmlSerializer(typeof(OgrenciListesi)); OgrenciListesi ogrenciListesi = new OgrenciListesi { Ogrenciler = new[] { new Ogrenci{ Adi = "Ali", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." } } }; using (StreamWriter dosya = File.CreateText("ogrenciListesi.xml")) { serializer.Serialize(dosya, ogrenciListesi); } Serileştirmenin yapılacağı Serileştirilecek nesne stream
  • 58. <?xml version="1.0" encoding="utf-8"?> <OgrenciListesi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.enterprisecoding.com"> <Ogrenciler> <Ogrenci Adi="Ali" Bolum="Bil. Müh." /> <Ogrenci Adi="Fatih" Bolum="Bil. Müh." /> <Ogrenci Adi="Melis" Bolum="Deri Müh." /> </Ogrenciler> </OgrenciListesi>
  • 59. <?xml version="1.0" encoding="utf-8"?> <OgrenciListesi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.enterprisecoding.com"> <Ogrenciler> <Ogrenci Adi="Ali" Bolum="Bil. Müh." /> <Ogrenci Adi="Fatih" Bolum="Bil. Müh." /> <Ogrenci Adi="Melis" Bolum="Deri Müh." /> </Ogrenciler> </OgrenciListesi>
  • 60. XmlSerializer serializer = new XmlSerializer(typeof(OgrenciListesi)); using (StreamReader dosya = File.OpenText("ogrenciListesi.xml")) { var ogrenciListesi=(OgrenciListesi)serializer.Deserialize(dosya); . . . }
  • 61. public class Ogrenci { public string Adi; public string Bolum; } List<Ogrenci> ogrenciler = new List<Ogrenci> { new Ogrenci{ Adi = "Ali", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Fatih", Bolum = "Bil. Müh." }, new Ogrenci{ Adi = "Melis", Bolum = "Deri Müh." } }; var bilMuhOgrencileri = ogrenciler.Where(ogrenci => ogrenci.Bolum == "Bil. Müh.");
  • 62. Aynı sorgunun farklı bir şekilde ifadesi; var bilMuhOgrencileri = from ogrenci in ogrenciler where ogrenci.Bolum == "Bil. Müh." select ogrenci; Sadece öğrencilerin adını sorgulamak için; var bilMuhOgrencileri = from ogrenci in ogrenciler where ogrenci.Bolum == "Bil. Müh." select ogrenci.Adi;
  • 63. Aynı sorgu, isimler sıralı şekilde; var bilMuhOgrencileri = from ogrenci in ogrenciler where ogrenci.Bolum == "Bil. Müh." orderby ogrenci.Adi ascending select ogrenci; Sorgu Sözdizimi (Query Syntax/Query Expression Syntax) Başka bir ifade ile; var bilMuhOgrencileri = ogrenciler .Where(ogrenci => ogrenci.Bolum == "Bil. Müh.") .OrderBy(ogrenci => ogrenci.Adi) .Select(ogrenci => ogrenci); Akıcı Sözdizimi (Fluent Syntax)
  • 64. Bir önceki örnekteki akıcı sözdizimini incelersek; var bilMuhOgrencileri = ogrenciler .Where(ogrenci => ogrenci.Bolum == "Bil. Müh.") .OrderBy(ogrenci => ogrenci.Adi) .Select(ogrenci => ogrenci); var filtrelenmis = ogrenciler.Where(ogrenci=>ogrenci.Bolum=="Bil. Müh."); var siralanmıs = filtrelenmis.OrderBy(ogrenci => ogrenci.Adi); var sorgu = siralanmıs.Select(ogrenci => ogrenci);
  • 65. Dış değişken kullanırken dikkati elden bırakmamalı; int[] sayilar = { 9, 2, 0, 8, 6, 7, 5, 4, 1, 3 }; int limit = 5; var sorgu = from sayi in sayilar where sayi > limit select sayi; int[] limitUstuSayilara1 = sorgu.ToArray(); // 9, 8, 6, 7 limit = 3; int[] limitUstuSayilara2 = sorgu.ToArray(); // 9, 8, 6, 7, 5, 4
  • 66. static void Main(string[] args) { Thread t = new Thread(EkranaYaz); t.Start(); for (int i = 0; i < 999; i++) { Console.Write("-"); } } private static void EkranaYaz() { for (int i = 0; i < 999; i++) { Console.Write("*"); } } Program çıktısı; -------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- ***************************************************************************************** ***********************************************------------------------------------------------------------- ---------------------------------------------------------------------------
  • 67. static void Main(string[] args) { Thread t = new Thread(EkranaYaz); t.Start(); for (int i = 0; i < 999; i++) { Başlatılan thread’in Console.Write("-"); bitmesi beklenir } t.Join(); } private static void EkranaYaz() { for (int i = 0; i < 999; i++) { Console.Write("*"); } }
  • 68. public delegate void ThreadStart(); public delegate void ParameterizedThreadStart (object obj); static void Main(string[] args) { Thread t = new Thread(EkranaYaz); t.Start("*"); for (int i = 0; i < 999; i++) { Console.Write("-"); } t.Join(); } private static void EkranaYaz(object mesaj) { for (int i = 0; i < 999; i++) { Console.Write(mesaj as string); } }
  • 71. 2002 - C# 1.0 Managed Kod
  • 72. 2005 - C# 2.0 Generics 2002 - C# 1.0 Managed Kod
  • 73. public static IEnumerable<int> To(this int ilk, int son) { for (var l = ilk; l <= son; l++) { yield return l; } } foreach (int i in 5.To(15)) { j = i*i; }
  • 74. 2007 - C# 3.0 LINQ 2005 - C# 2.0 Generics 2002 - C# 1.0 Managed Kod
  • 75. List<int> ogrenciIdleri = new List<int>(); foreach (Ogrenci ogrenci in ogrenciler) { if (ogrenci.BolumID == 1) { ogrenciIdleri.Add(ogrenci.ID); } } var ogrenciIdleri = ogrenciler .Where(ogrenci => ogrenci.BolumID == 1) .Select(ogrenci => ogrenci.ID); var ogrenciIdleri = from ogrenci in ogrenciler where ogrenci.BolumID == 1 select ogrenci.ID;
  • 76. 2010 - C# 4.0 Dinamik programlama 2007 - C# 3.0 LINQ 2005 - C# 2.0 Generics 2002 - C# 1.0 Managed Kod
  • 77. object hesapMakinesi = HesapMakinesiniGetir(); Type hesapMakinesiTuru = hesapMakinesi.GetType(); object sonuc = hesapMakinesiTuru.InvokeMember("Ekle", BindingFlags.InvokeMethod, null, hesapMakinesi, new object[] { 1, 2}); int toplam = Convert.ToInt32(sonuc); dynamic hesapMakinesi = HesapMakinesiniGetir(); int toplam = hesapMakinesi.Add(1, 2);
  • 78. Bildirimsel C# 3.0 Dinamik Eşzamanlılık C# 4
  • 80. ... - C# v.Next Asenkron Programlama 2010 - C# 4.0 Dinamik programlama 2007 - C# 3.0 LINQ 2005 - C# 2.0 Generics 2002 - C# 1.0 Managed Kod
  • 82. var veri = VeriyiIndir(...); VeriyiIsle(veri); VeriyiIndirAsync(... , veri => { VeriyiIsle(veri); });
  • 84. public TResult VeriyiIndir(TParam parametre); … public IAsyncResult BeginVeriyiIndir (TParam parametre, AsyncCallback geriCagri, object durum); public TResult EndVeriyiIndir (IAsyncResult asenkronSonuc);
  • 85. public TResult VeriyiIndir(TParam parametre); … public void VeriyiIndirAsync(TParam parametre); public event VeriIndirTamamlandiEventHandler VeriIndirTamamlandi; public delegate void VeriIndirTamamlandiEventHandler( object sender, VeriIndirTamamlandiEventArgs eventArgs); public class VeriIndirTamamlandiEventArgs : AsyncCompletedEventArgs { public TResult Sonuc { get; } }
  • 91. private void adresleriBul_Click(object sender, EventArgs e) { <adresleriBul_Click>d__0 d__ = new <adresleriBul_Click>d__0(0); d__.<>4__this = this; d__.sender = sender; d__.e = e; d__.MoveNextDelegate = new Action(d__.MoveNext); d__.$builder = VoidAsyncMethodBuilder.Create(); d__.MoveNext(); }
  • 92. [CompilerGenerated] private sealed class <adresleriBul_Click>d__0 { private bool $__disposing; private bool $__doFinallyBodies; public VoidAsyncMethodBuilder $builder; private int <>1__state; public EventArgs <>3__e; public object <>3__sender; public AnaEkran <>4__this; private string <1>t__$await5; private TaskAwaiter<string> <a1>t__$await6; public string <adress>5__1; public Match <eslesim>5__4; public MatchCollection <eslesimler>5__3; public string <icerik>5__2; public EventArgs e; public Action MoveNextDelegate; public object sender; [DebuggerHidden] public <adresleriBul_Click>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] public void Dispose() { this.$__disposing = true; this.MoveNext(); this.<>1__state = -1; } public void MoveNext() { try { this.$__doFinallyBodies = true; if (this.<>1__state != 1) { if (this.<>1__state == -1) { return; } this.<adress>5__1 = "http://www.enterprisecoding.com/blog/"; this.<a1>t__$await6 = new WebClient().DownloadStringTaskAsync(this.<adress>5__1).GetAwaiter<string>(); this.<>1__state = 1; this.$__doFinallyBodies = false; if (this.<a1>t__$await6.BeginAwait(this.MoveNextDelegate)) { return; } this.$__doFinallyBodies = true; } this.<>1__state = 0; this.<1>t__$await5 = this.<a1>t__$await6.EndAwait(); this.<icerik>5__2 = this.<1>t__$await5; this.<eslesimler>5__3 = Regex.Matches(this.<icerik>5__2, @"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-@/$,]*", RegexOptions.IgnoreCase); IEnumerator CS$5$0002 = this.<eslesimler>5__3.GetEnumerator(); try { while (CS$5$0002.MoveNext()) { this.<eslesim>5__4 = (Match) CS$5$0002.Current; this.<>4__this.adresListesi.Items.Add(this.<eslesim>5__4.Value); } } finally { if (this.$__doFinallyBodies) { IDisposable CS$0$0003 = CS$5$0002 as IDisposable; if (CS$0$0003 != null) { CS$0$0003.Dispose(); } } } this.<>1__state = -1; this.$builder.SetCompleted(); } catch (Exception) { this.<>1__state = -1; this.$builder.SetCompleted(); throw; } } }
  • 94. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 95. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 96. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 97. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 98. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 99. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 100. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }
  • 101. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); } 
  • 102. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); } 
  • 103. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }  
  • 104. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }  
  • 105. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }   
  • 106. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }     
  • 107. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }      
  • 108. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }       
  • 109. async void DoWorkAsync() { var t1 = ProcessFeedAsync("www.acme.com/rss"); var t2 = ProcessFeedAsync("www.xyznews.com/rss"); await Task.WhenAll(t1, t2); DisplayMessage("Done"); } async Task ProcessFeedAsync(string url) { var text = await DownloadFeedAsync(url); var doc = ParseFeedIntoDoc(text); await SaveDocAsync(doc); ProcessLog.WriteEntry(url); }       
  • 110. private void adresleriBul_Click(object sender, EventArgs e) { var adress = "http://www.enterprisecoding.com/blog/"; var icerik = new WebClient().DownloadString(adress); var eslesimler = Regex.Matches(icerik, @"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=- @/$,]*", RegexOptions.IgnoreCase); foreach (Match eslesim in eslesimler) { adresListesi.Items.Add(eslesim.Value); } }
  • 111. delegate void EslesimleriEkleCallback(MatchCollection eslesimler); private void adresleriBul_Click(object sender, EventArgs e) { var islem = new Thread(new ThreadStart(AdressleriBul)); islem.Start(); } private void AdressleriBul() { var adress = "http://www.enterprisecoding.com/blog/"; var icerik = new WebClient().DownloadString(adress); var eslesimler = Regex.Matches(icerik, @"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-@/$,]*", RegexOptions.IgnoreCase); if (adresListesi.InvokeRequired) {//Fonksiyon ayrı thread’den çağırılmış var callback = new EslesimleriEkleCallback(EslesimleriEkle); Invoke(callback, new[] { eslesimler }); } else { //Aynı thread, doğrudan çağırılabilir EslesimleriEkle(eslesimler); } } private void EslesimleriEkle(MatchCollection eslesimler) { foreach (Match eslesim in eslesimler) { adresListesi.Items.Add(eslesim.Value); } }
  • 112. private async void adresleriBul_Click(object sender, EventArgs e) { var adress = "http://www.enterprisecoding.com/blog/"; var icerik = await new WebClient().DownloadStringTaskAsync(adress); var eslesimler = Regex.Matches(icerik, @"(?<Protocol>w+)://(?<Domain>[w@][w.:@]+)/?[w.?=%&=-@/$,]*", RegexOptions.IgnoreCase); foreach (Match eslesim in eslesimler) { adresListesi.Items.Add(eslesim.Value); } }
  • 113. ... - C# v.Next Next CaaS ... - C# v.Next Asenkron Programlama 2010 - C# 4.0 Dinamik programlama 2007 - C# 3.0 LINQ 2005 - C# 2.0 Generics 2002 - C# 1.0 Managed Kod
  • 114. Sınıf Meta-programlama Oku-Çalıştır-Yaz public Foo Döngüsü Dil Nesne Modeli alan private X string .NET Kaynak Kodu Source code Assembly Source code Source code Compiler Derleyici Source code
  • 117. 3D Derinlik Algılayıcıları RGB Kamera Çoklu Mikrofon Dizisi Hareket Motoru
  • 119. ShoulderRight ShoulderLeft ElbowRight Head ElbowLeft WristRight WristLeft HandRight HandLeft ShoulderCenter Spine HipCenter HipRight HipLeft KneeRight KneeLeft AnkleRight AnkleLeft FootLeft FootLeft

Editor's Notes

  • #5: This is the fully animated slide.