> For the complete documentation index, see [llms.txt](https://cnahmet.gitbook.io/asp-net-notlarim/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cnahmet.gitbook.io/asp-net-notlarim/nesne-tabanli-programlama/class.md).

# Class

![Class Mantığı - 1](/files/-MLN28cF7kZQ416uQeSg)

![Class Mantığı - 2](/files/-MLN2ab1HrFQApSd24o8)

**Class**, nesnelerin özelliklerini, davranışlarını ve başlangıç durumlarını tanımlamak için kullanılan şablonlara verilen isimdir.

**Class** tan türetilen her bir veri yapısına **object** denir.&#x20;

Bir **class** içerinde değişken olarak tanımlanan bilgilere **property** denir.

Bir **object** in davranışlarını belirleyen yapılara **method** denir.

```aspnet
class Ogrenci{
    public int OgrNo { get; set; }
    public string Ad { get; set; }
    public string Sube { get; set; }
}
    
    // void Main fonksiyonu içerisinde
    
Ogrenci ogr1 = new Ogrenci();
    ogr1.Ad = "Ahmet";
    ogr1.OgrNo = 123;
    ogr1.Sube = "10D";
    
Console.WriteLine($"Adı: {ogr1.Ad} No: {ogr1.OgrNo} Şube: {ogr1.Sube}");
```

```aspnet
/* 
Birden fazla bilgi yazdırmak için liste içine alıp döngüde çalıştırılabilir.
*/

Ogrenci[] ogrenciler = new Ogrenci[5];
ogrenciler[0] = ogr1;
ogrenciler[1] = ogr2;
ogrenciler[2] = ogr3;
ogrenciler[3] = ogr4;
ogrenciler[4] = ogr5;

for(int i = 0; i<ogrenciler.Length;i++){
    Console.WriteLine($"{i} - {ogrenciler[i].Ad} {ogrenciler[i].OgrNo} {ogrenciler[i].Sube} ");
}


```

{% hint style="success" %}
**`prop`** yazarak otomatik olarak bir property oluşturulabilir.
{% endhint %}

## Yukarıdaki bilgilerle bir uygulama yapalım.

```aspnet
/*
1-) Product class => name, price, description
2-) Sınırsız sayıda ürün bilgisini alıp bir dizinin içinde saklayınız.
3-) Ürün adetini kullanıcı belirtsin
4-) Eklenen ürünler listelensin
*/

using System;

namespace Classlar
{
class Product{
    public string Name { get; set; }
    public double Price { get; set; }
    public string Description { get; set; }
}



    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Adet: ");
            int adet = int.Parse(Console.ReadLine());

            Product[] products = new Product[adet];

            int i=0;
            Product prd;

            do{
                prd = new Product();
                Console.Write("Ürün Adı: ");
                prd.Name = Console.ReadLine();

                Console.Write("Ürün Fiyatı: ");
                prd.Price = double.Parse(Console.ReadLine());

                Console.Write("Ürün Açıklaması: ");
                prd.Description = Console.ReadLine();

                products[i] = prd;
                i++;
            }
            while(adet>i);

            Console.WriteLine("*****************");
            
            for (int j = 0; j < products.Length; j++)
            {
                Console.WriteLine($"Ürün Adı: {products[j].Name} - Ürün Fiyatı: {products[j].Price} - Ürün Açıklaması: {products[j].Description}");
            }

        }
    }
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cnahmet.gitbook.io/asp-net-notlarim/nesne-tabanli-programlama/class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
