# 3.ชนิดของข้อมูล

💬 ก่อนที่เราจะเขียนโค้ดตัวแรกจริงๆกัน เราต้องรู้จักกับสิ่งที่เรียกว่า **ชนิดของข้อมูล** หรือ **data type** เสียก่อน ซึ่งข้อมูลแต่ละชนิดก็จะเหมาะกับงานแต่ละแบบ

{% hint style="danger" %}
ถ้าเราไม่เข้าใจจุดนี้มันก็เหมือนกับเราเอาค้อนไปเลื่อยไม้นั่นเอง เพราะเราไม่เข้าใจการทำงานพื้นฐานของข้อมูลแต่ละรูปแบบ ซึ่งจุดนี้ผมเจอมาเยอะมากเลยแม้กระทั่งนักพัฒนาที่เขียนโปรแกรมมาเป็น 10 ปีบางคนก็ไม่ได้เข้าใจในจุดนนี้อย่างถ่องแท้ ทำให้เวลาเจอข้อผิดพลาดก็จะพากัน งงๆ ว่าเกิดอะไรขึ้น
{% endhint %}

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

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

### 👨‍🚀 ประเภทของข้อมูลหลัก

ในโลกของการเขียนโปรแกรม เราควรต้องรู้จักประเภทข้อมูล 4 ตัวแรกมีตามนี้เบย

| Data type | ใช้กับ                                        | ตัวอย่างข้อมูล  |
| --------- | --------------------------------------------- | --------------- |
| int       | ตัวเลขจำนวนเต็ม                               | 1000            |
| double    | ตัวเลขจำนวนเต็ม หรือ ทศนิยม                   | 32.76           |
| string    | ข้อความ **และจะต้องอยู่ภายใต้ double quote**  | "Hello"         |
| bool      | ข้อมูลที่เป็น **จริง** หรือ **เท็จ** เท่านั้น | true หรือ false |


---

# 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/datatype.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.
