# 14.มารู้จักกับ Array กัน

💬 พอได้ลองเขียนโค้ดไปได้ซักพัก พวกเราจะพบว่าตัวแปรที่เราสร้างไว้มันค่อนข้างวุ่นวายเลยใช่ไหม ลองคิดดูนะว่าถ้าเราต้องเก็บคะแนนของนักเรียน 1 คนมีต้องมีตัวแปร 1 ตัวชิมิ แต่ถ้าเกิดว่าเราต้องเก็บข้อมูลของนักเรียนซัก 100 คนขึ้นมาละ? ตัวแปรของเราคงมีอย่างต่ำคือ 100 เลยตัวใช่ไหม? ดังนั้นในรอบนี้เราจะลองมารู้จักกับการจัดการกับตัวแปรประเภทเดียวที่ใช้ซ้ำๆกันดู นั่นคือเรื่องของ **Array** นั่นเอง

{% embed url="<https://www.youtube.com/watch?v=4fF3kTiEygw&list=PLUjAn8nwWnijERZ3HpzBk7NfSrau74_lQ&index=28>" %}

## 🎥 ตัวอย่างการใช้ Array กับ For loop

{% embed url="<https://www.youtube.com/watch?v=Kva8_qeGcWE&list=PLUjAn8nwWnijERZ3HpzBk7NfSrau74_lQ&index=29>" %}

## 🎯 สรุปสั้นๆ

### 👨‍🚀 Array คือ

กลุ่มของข้อมูลที่มีชนิดของข้อมูลเป็นชนิดเดียวกัน แล้วเราทำการเก็บมารวมไว้ภายในตัวแปรเดียว ส่วนเมื่อเราต้องการเรียกใช้ ก็สามารถทำได้ผ่านการระบุตำแหน่ง หรือคำศัพท์จริงๆของมันคือ **Indexer** นั่นเอง

### 👨‍🚀 ประเภทของ Array

Array ที่เราใช้กันอยู่มีทั้งหมด 3 แบบ โดยแต่ละแบบก็จะเหมาะกับประเภทของคนละชนิดกันด้วยนะจุ๊

1. Single Dimensional Array
2. Multidimensional Array
3. Jagged Array


---

# Agent Instructions: 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://www.saladpuk.com/beginner-1/csharp101/basic/array.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.
