VuePressVuePress
Home
Get Started
Home
Get Started
  • Temel Kavramlar

    • Type Declarations (Tur Bildirimleri)
    • Access Modifiers (Erişim Değiştiricileri)
    • Erişimci (Accessor)
  • Metotlar ve İşlemler

    • Metotlar (Methods)
    • Geri Dönüş Türleri (Return Types)
    • Try-Catch Kullanımı
  • Veri Yapıları

    • Koleksiyon Arayüzleri (Collection Interfaces)
    • LINQ Sorguları
  • İleri Konular

    • Dependency Injection Servisleri
    • DbContext - OnModelCreating Metodu
  • DbContext ve Entity Framework

    • Entity Framework Core - Fluent API ve İlişkiler Rehberi

Type Declarations (Tur Bildirimleri)

Nedir?

Tur bildirimleri, .NET'te farklı veri yapılarını tanımlamak için kullanılan anahtar kelimelerdir.

Tur Bildirimi Cesitleri

1. class - Nesne Tipi

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

var person = new Person { Name = "Ali", Age = 25 };

2. struct - Deger Tipi

public struct Point
{
    public int X { get; set; }
    public int Y { get; set; }
}

Point p = new Point { X = 10, Y = 20 };

3. interface - Sozlesme

public interface IRepository
{
    void Add(object item);
    void Remove(object item);
}

public class UserRepository : IRepository
{
    public void Add(object item) { }
    public void Remove(object item) { }
}

4. enum - Sabit Degerler

public enum Status
{
    Active = 1,
    Inactive = 2,
    Pending = 3
}

Status status = Status.Active;

5. record - Veri Odakli Sinif (C# 9.0+)

public record Person(string Name, int Age);

var person = new Person("Ali", 25);

6. delegate - Metot Referansi

public delegate void Notify(string message);

public class EventPublisher
{
    public event Notify OnNotify;
    
    public void SendNotification(string msg)
    {
        OnNotify?.Invoke(msg);
    }
}

7. namespace - Kod Organizasyonu

namespace MyApp.Services
{
    public class UserService
    {
        public void CreateUser(string name) { }
    }
}

using MyApp.Services;
var service = new UserService();

8. abstract - Soyut Sinif

public abstract class Animal
{
    public abstract void Speak();
    
    public void Move()
    {
        Console.WriteLine("Hareket ediyor");
    }
}

public class Dog : Animal
{
    public override void Speak()
    {
        Console.WriteLine("Hav hav");
    }
}

9. sealed - Kalitim Engelleme

public sealed class FinalClass
{
    public void DoSomething() { }
}

// Hata: sealed siniftan kalitim yapilamaz
public class DerivedClass : FinalClass { }

10. static - Nesne Olmadan Erisim

public static class MathHelper
{
    public static int Add(int a, int b)
    {
        return a + b;
    }
}

int result = MathHelper.Add(5, 3);

11. partial - Birden Fazla Dosya

// UserService.cs
public partial class UserService
{
    public void CreateUser(string name) { }
}

// UserService.Methods.cs
public partial class UserService
{
    public void DeleteUser(int id) { }
}

12. readonly - Degistirilemez

public class Configuration
{
    public readonly string ConnectionString = "Server=localhost";
    
    public readonly int MaxConnections = 100;
}

var config = new Configuration();
// config.ConnectionString = "..."; // Hata

Kombinasyonlar

// public abstract class
public abstract class BaseService { }

// public sealed class
public sealed class FinalService { }

// public static class
public static class Utilities { }

// internal interface
internal interface IInternal { }

// private class
private class PrivateClass { }

Karsilastirma Tablosu

TurReferans/DegerKalitimOrnegi
classReferansEvetpublic class Person { }
structDegerHayirpublic struct Point { }
interfaceReferansEvetpublic interface IService { }
enumDegerHayirpublic enum Status { }
recordReferansEvetpublic record Person(string Name);
delegateReferansHayirpublic delegate void Action();
Last Updated:: 6/7/26, 12:33 PM
Contributors: yigitumretastan
Next
Access Modifiers (Erişim Değiştiricileri)