DEV Community

Ozodbek
Ozodbek

Posted on

To'plamlar | array, list, queue, stack, dictionary

Ushbu maqolada nimalarni o'rganamiz ?

1 - _To'plamlar nima_ ?
2 - _Array nima_ ?
3 - _List nima_ ?
4 - _Queue nima _?
5 - _Dictionary nima_ ?

Javoblarni birma bir ko'rib chiqamiz.
1. Ma'lumot turdagi bir nechta ma'lumotni o'zida jamlay oladigan ma'lumot turi. Siz C# dasturlash tilida o'rgangan int, string, char, bool, double, struct, class, record va hokazo ma'lumot turlari, o'zlarida atigi bitta ma'lumotni saqlay oladi, Array, List, Queue, Dictionar esa bundan mustasno va C#da eng ko'p ishlatiladigan mashhur turlardir. Endi esa shu 4 ta asosiy turlarni birma bir ko'rib chiqamiz.

2. Array - bu (Massiv) ham deyishadi. Lekin massiv demasdan array deganimiz yaxshiroq. Array bu bir xil tipdagi bir nechta ma'lumotlarni saqlashda ishlatilinadi. Array bu reference type. Tabiiyki xotiradan Heap dan joy oladi. Elemenlari ham default qiymat oladi. String typeda bo'lsa null oladi, int & double bo'lsa 0 qiymat oladi, bool bo'lsa false. E'lon qilishni ko'ramiz: Misol uchun sizda bir nechta string typedagi mevalar nomi bo'lsa, uni bunday saqlaysiz 👇

string[] mevalar = {"olma", "nok", "gilos"};
Enter fullscreen mode Exit fullscreen mode

Agar sonlar saqlamoqchi bo'lsangiz 👇

int[] sonlar = {1, 3, 5};
Enter fullscreen mode Exit fullscreen mode

int[] deganimiz bu shunchaki butun sonlarni qabul qilish uchun e'lon qilindi. sonlar esa istalgancha o'zgaruvchi nomi. {} qavs ichidagilar esa arrayni elementlari deb ataladi. Elementlarga esa index orqali murojaat qilinadi. Indexlar esa 0 dan boshlanib array lengthgacha teng bo'ladi..

C# xususiyatlaridan bir shingil code

var son = new[] {1, 3, 5, 6};
var meva = new[] {"olma", "shaftoli"};
Console.WriteLine(string.Join(", ", son));
Console.WriteLine(string.Join(", ", meva));
Enter fullscreen mode Exit fullscreen mode

Yana biri esa Collection expression

int[] son = [1, 4, 5];
Enter fullscreen mode Exit fullscreen mode

vahokazo, qolgan featurelarni ko'rib olishingiz mumkin (practice orqali)

*3. * Davomi bor....

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more