# 11.การทำงานซ้ำๆด้วย Do While

💬 หลังจากที่เราเห็นตัวช่วยในการจัดการกับงานที่ทำงานซ้ำๆหลายๆรอบไปละ ในรอบนี้เราลองมาดูการเขียน **Do..While loop statements** กันดูบ้างนะครับว่ามันจะต่างกับ **While loop statements** ยังไงบ้าง

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

## 🎥 ตัวอย่างการใช้คำสั่ง Do While loop statements

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

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

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

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

### 👨‍🚀 คำสั่ง Do While มาตรฐาน

```csharp
do
{
  // Do something
} while( เงื่อนไข );
```

{% hint style="info" %}
คำสั่ง do while จะต่างกับ while ธรรมดาตรงที่ do while จะยอมปล่อยให้เข้าไปทำในวงเล็บ { } ก่อน 1 รอบ แล้วค่อยตรวจสอบเงื่อนไขว่ามันจะได้กลับมาทำหรือเปล่า ซึ่งในขณะที่ while loop จะไม่ยอมให้เข้าไปทำในวงเล็บเลยถ้าเงื่อนไขไม่ถูกต้อง

* **do while** > มันให้ลองเล่นก่อน 1 รอบ แล้วค่อยดูเงื่อนไข
* **while** > ตรวจเงื่อนไขก่อนค่อยให้เล่น
  {% endhint %}


---

# 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/do-while.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.
