Sunum yükleniyor. Lütfen bekleyiniz

Sunum yükleniyor. Lütfen bekleyiniz

C# - C Sharp Sinan TECER Programlama Dilleri Proje Ödevi

Benzer bir sunumlar


... konulu sunumlar: "C# - C Sharp Sinan TECER Programlama Dilleri Proje Ödevi"— Sunum transkripti:

1 C# - C Sharp Sinan TECER 04104426 Programlama Dilleri Proje Ödevi

2 C# – Giriş Microsoft tarafından 2000 yılında piyasaya çıkarılmıştır.
Tümüyle nesne tabanlıdır. Yeni nesil sağlam ve dayanıklı bir dildir. Java,C++ ve Delphi den fazlasıyla faydalanmıştır.

3 C# – Giriş Tümüyle Nesne Tabanlıdır.
Genel bakış.. C++, Java:ilkel tipleri objelerle birlikte çalışmaz. Smalltalk, Lisp: ilkel tipleri objedir ama iyi performans için yüksek maliyet gerektirir. C# herhangi performans maliyeti olmadan birleştirme yapar. Sistem boyunca kolay anlaşılabilirlik söz konusudur Geliştirilmiş yeniden kullanma ve genişletilebilirlik Yeni tipler: Decimal, SQL… Collections, gibi., her tip için çalışma

4 C# – Giriş Sağlam ve Dayanıklı Yazılım
Garbage collection memory leaks problemi ve başıboş pointer problemi olmaz. Exceptions Error handling, sonradan olmaz Type-safety Tanımlanmayan değişkenlerin atama sorunu olmaz.

5 C# – Giriş Kod Koruma C++ heritage Birlikte Çalışabilirlik
Namespaces, enums, unsigned tipleri, pointer lar (güvensiz koddur), gibi. Gereksiz kurban Birlikte Çalışabilirlik Bu konuda çalışma yapan en önemli yazılım MS C# implementasyonu XML, SOAP, COM, DLL lerle ve herhangi .NET dili ile etkin bir şekilde etkileşim içindedir. .NET teki uzun kod satırları Kısa zamanda öğrenilebilirlik Artan verimlilik

6 Hello World using System; class Hello { static void Main() {
Console.WriteLine("Hello world"); }

7 C# Program Structure Namespace Type declarations Memberlar Organizasi
Diğer namespaceler ve tipleri içerir Type declarations Class lar, struct lar, interface ler, enum yapısı, ve delegate lerdir Memberlar Constant-lar, field-lar, method lar, propertie-ler, indexer-lar, event-ler, operator-ler, constructor-lar, destructor-lar Organizasi Header file yok. Kod tek satır-satır yazılır. Deklaraston ve diğer bağımlılıklar yok.

8 C# Program Structure using System; namespace System.Collections {
public class Stack Entry top; public void Push(object data) { top = new Entry(top, data); } public object Pop() { if (top == null) throw new InvalidOperationException(); object result = top.data; top = top.next; return result;

9 Tip Sistemi Değer tipi Referans tipleri Doğrudan veri içerir
Null olamaz Referans tipleri Nesnelere referans içerirler. Null oalbilir. int i = 123; string s = "Hello world"; i 123 s "Hello world"

10 Tip Sistemi Değer tipleri Referans tipleri Primitive int i;
Enum enum State { Off, On } Struct struct Point { int x, y; } Referans tipleri Class class Foo: Bar, IFoo {...} Interface interface IFoo: IBar {...} Array string[] a = new string[10]; Delegate delegate void Empty();

11 Önceden Tanımlanmış Türler
C# Diğer türler types Reference object, string Signed sbyte, short, int, long Unsigned byte, ushort, uint, ulong Character char Floating-point float, double, decimal Logical bool Diğer türler, sistem içindeki takma tiplerle sağlanır. Örneğin, int == System.Int32

12 Class Yapısı Single inheritance Multiple interface implementation
Class member-ları Constant, field, method, propertie, indexer, event, operator, constructor, destructor Sabit ve özel memberlar. İç içe türler Class üyelerine erişim public, protected, internal, private

13 Interface Yapısı Multiple inheritance
method, propertie, indexer ve event içerebilir Private interface implementasyonu interface IDataBound { void Bind(IDataBinder binder); } class EditBox: Control, IDataBound void IDataBound.Bind(IDataBinder binder) {...}

14 Enum Yapısı Güçlü yazılmış Temel türleri
İmplicit çevirisi yoktur int e veya intten Operator: +, -, ++, --, &, |, ^, ~ Temel türleri Byte, short, int, long enum Color: byte { Red = 1, Green = 2, Blue = 4, Black = 0, White = Red | Green | Blue, }

15 Delegate Yapısı Nesne tabanlı fonksiyon pointerı Çoklu alıcılar
Her delege için bir çağrı listesi vardır. Thread-safe + ve – operation ları için Eventlerle birlikte kullanılırlar. delegate void MouseEvent(int x, int y); delegate double Func(double x); Func func = new Func(Math.Sin); double x = func(1.0);

16 Birleşik Tip Sistemi Herşey Objedir.
Tüm tipler objeden inherit edilir. Datanın herhangi bir parçası extara iş gerektirmeden saklanabilir,taşına bilir veya değiştirilebilir. object Stream Hashtable int double MemoryStream FileStream

17 Propertie Yapısı Propertie ler “akıllı alan” dır
doğal syntax, accessors, inlining Set ve Get fonksiyonlarının gelişmiş halidir. public class Button: Control { private string caption; public string Caption { get { return caption; } set { caption = value; Repaint(); Button b = new Button(); b.Caption = "OK"; String s = b.Caption;

18 Indexer Yapısı Indexerlar “akıllı array” dir Overload edilebilir
public class ListBox: Control { private string[] items; public string this[int index] { get { return items[index]; } set { items[index] = value; Repaint(); ListBox listBox = new ListBox(); listBox[0] = "hello"; Console.WriteLine(listBox[0]);

19 Event Yapısı Kaynak Event imzası tanımlanır.
public delegate void EventHandler(object sender, EventArgs e); Event i define et, işlemi bağla public class Button { public event EventHandler Click; protected void OnClick(EventArgs e) { if (Click != null) Click(this, e); } }

20 Event Yapısı Handling Define ve register event handler
public class MyForm: Form { Button okButton; public MyForm() { okButton = new Button(...); okButton.Caption = "OK"; okButton.Click += new EventHandler(OkButtonClick); } void OkButtonClick(object sender, EventArgs e) { ShowMessage("You pressed the OK button");

21 Attribute Yapısı public class OrderProcessor { [WebMethod]
public void SubmitOrder(PurchaseOrder order) {...} } [XmlRoot("Order", Namespace="urn:acme.b2b-schema.v1")] public class PurchaseOrder [XmlElement("shipTo")] public Address ShipTo; [XmlElement("billTo")] public Address BillTo; [XmlElement("comment")] public string Comment; [XmlElement("items")] public Item[] Items; [XmlAttribute("date")] public DateTime OrderDate; public class Address {...} public class Item {...}

22 Attribute Yapısı Attributes ile Tamamen genişletilebilir Type-safe
Member ve üyelere bağlama yapılabilir Çalışma zamanında işlem yapılabilir Tamamen genişletilebilir Bir class basti bir biçimde System.Attribute den inherit edilebilir Type-safe Argument ler compile zamanında kontrol edilir .NET Framework le kapsamlı kullanılırlar XML, Web Servisleri, güvenlik, serileştirme, component model, COM ve P/Invoke birlikte çalışma, kod konfigürasyonu…

23 XML Yorum Yapısı class XmlElement { /// <summary>
/// Returns the attribute with the given name and /// namespace</summary> /// <param name="name"> /// The name of the attribute</param> /// <param name="ns"> /// The namespace of the attribute, or null if /// the attribute has no namespace</param> /// <return> /// The attribute value, or null if the attribute /// does not exist</return> /// <seealso cref="GetAttr(string)"/> /// public string GetAttr(string name, string ns) { ... }

24 Statement ve Expression
C++ yapısıyla aynıdır If, while, do bool conditionını gerektirir goto blok içinde zıplama yapamaz Switch statement foreach statement Checked ve unchecked statement void Foo() { i == 1; // error }

25 foreach Statement Yapısı
Arraylerin iterasyonu ile Kullanıcının tanımladığı colleksiyonlar ile public static void Main(string[] args) { foreach (string s in args) Console.WriteLine(s); } foreach (Customer c in customers.OrderBy("name")) { if (c.Orders.Count != 0) { ... }

26 Operator Overloading İlk Class kullanıcının yarattığı tiptir
Base class kütüphanesinde kullanılır Decimal, DateTime, TimeSpan UI kütüphanesiyle kullanılır Unit, Point, Rectangle SQL integrasyonu ile kullanılır SQLString, SQLInt16, SQLInt32, SQLInt64, SQLBool, SQLMoney, SQLNumeric, SQLFloat…

27 Koşullu derlemeler #define, #undef #if, #elif, #else, #endif
Basit true-false yapısı Koşul metodları public class Debug { [Conditional("Debug")] public static void Assert(bool cond, String s) { if (!cond) { throw new AssertionException(s); }

28 Unsafe Kod Yapısı Platform bir çok durumu kapsar Unsafe kod
Low-level kod “kutu içinde” Güvensiz pointer atamaları sağlar bildirme bağlantıları Sabit durum Basit olarak “inline C” unsafe void Foo() { char* buf = stackalloc char[256]; for (char* p = buf; p < buf + 256; p++) *p = 0; ... }

29 Unsafe Kod Yapısı class FileStream: Stream { int handle;
public unsafe int Read(byte[] buffer, int index, int count) { int n = 0; fixed (byte* p = buffer) { ReadFile(handle, p + index, count, &n, null); } return n; [dllimport("kernel32", SetLastError=true)] static extern unsafe bool ReadFile(int hFile, void* lpBuffer, int nBytesToRead, int* nBytesRead, Overlapped* lpOverlapped);

30 Daha Fazla Bilgi İçin http://msdn.microsoft.com/net
.NET SDK ve dökümantasyonu indirilebilir. .NET PDC den çeşitli dökümanlara ulaşılabilir. news://msnews.microsoft.com Microsoft/public/dotnet/csharp/general


"C# - C Sharp Sinan TECER Programlama Dilleri Proje Ödevi" indir ppt

Benzer bir sunumlar


Google Reklamları