Thuta Learning
C#
BasicProgrammingအခြေခံ

Syntax & Hello World

C#သင်ခန်းစာ 420 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Syntax & Hello World ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
  • Normal, boundary နဲ့invalid cases ကိုကိုယ်တိုင်စမ်းနိုင်ရန်
  • Readable, type-safe နဲ့testable C# code ရေးနိုင်ရန်

ရိုးရိုးလေး ရှင်းပြမယ်

Syntax & Hello World ကို ရိုးရိုးလေးနားလည်မယ်

C# program တစ်ခုရဲ့ အခြေခံတည်ဆောက်ပုံမှာ using , namespace , class , Main method တို့ ပါဝင်ပါတယ်။ အစမှာ syntax နည်းနည်းများတယ်လို့ထင်ရပေမယ့် တစ်ခါနားလည်သွားရင် project တွေကို စနစ်တကျတည်ဆောက်နိုင်စေတဲ့ အခြေခံအုတ်မြစ်ပါ။

Problem → Why → Solution

ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ

Indentation ကိုscope လို့ယူဆခြင်း၊ semicolon သို့brace မကိုက်ခြင်းက misleading compiler errors ဆက်တိုက်ဖြစ်စေပါတယ်။

ဖြစ်လေ့ရှိတဲ့အမှား

Happy path တစ်ခု run အောင်ရုံဖြင့် code မှန်ကန်၊ maintainable နဲ့production-ready ဖြစ်ပြီဟုယူဆခြင်း။

Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်

C# syntax တွင် identifiers ကcase-sensitive ဖြစ်ပြီး statements, expressions, blocks, namespaces/types နဲ့top-level statements တို့ကို compiler ကသတ်မှတ်ထားသော grammar အတိုင်းဖတ်ပါတယ်။ Formatting က readability ကိုကူညီပေမယ့် scope ကို braces နဲ့structure ကဆုံးဖြတ်ပါတယ်။

Mental Model
  1. Typed input
  2. C# expression + method
  3. CLR value / object state

Syntax & Hello World ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်

အဓိက Syntax / Pattern

csharp
using System;

namespace MyNamespace
{
    class MyClass
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
        }
    }
}

C# syntax တွင် identifiers ကcase-sensitive ဖြစ်ပြီး statements, expressions, blocks, namespaces/types နဲ့top-level statements တို့ကို compiler ကသတ်မှတ်ထားသော grammar အတိုင်းဖတ်ပါတယ်။ Formatting က readability ကိုကူညီပေမယ့် scope ကို braces နဲ့structure ကဆုံးဖြတ်ပါတယ်။

Code ကို အဆင့်လိုက်ဖတ်မယ်

  1. Typed inputusing System;

    C# program တစ်ခုရဲ့ အခြေခံတည်ဆောက်ပုံမှာ using , namespace , class , Main method တို့ ပါဝင်ပါတယ်။ အစမှာ syntax နည်းနည်းများတယ်လို့ထင်ရပေမယ့် တစ်ခါနားလည်သွားရင် project တွေကို စနစ်တကျတည်ဆောက်နိုင်စေတဲ့ အခြေခံအုတ်မြစ်ပါ။

  2. C# expression + methodstatic void Main(string[] args)

    C# syntax တွင် identifiers ကcase-sensitive ဖြစ်ပြီး statements, expressions, blocks, namespaces/types နဲ့top-level statements တို့ကို compiler ကသတ်မှတ်ထားသော grammar အတိုင်းဖတ်ပါတယ်။ Formatting က readability ကိုကူညီပေမယ့် scope ကို braces နဲ့structure ကဆုံးဖြတ်ပါတယ်။

  3. CLR value / object state}

    Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။

Execution Flow
  1. Typed input
  2. C# expression + method
  3. CLR value / object state

Success

Syntax & Hello World ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်

Failure

Indentation ကိုscope လို့ယူဆခြင်း၊ semicolon သို့brace မကိုက်ခြင်းက misleading compiler errors ဆက်တိုက်ဖြစ်စေပါတယ်။

C# program တစ်ခုရဲ့ အခြေခံတည်ဆောက်ပုံမှာ using, namespace, class, Main method တို့ ပါဝင်ပါတယ်။ အစမှာ syntax နည်းနည်းများတယ်လို့ထင်ရပေမယ့် တစ်ခါနားလည်သွားရင် project တွေကို စနစ်တကျတည်ဆောက်နိုင်စေတဲ့ အခြေခံအုတ်မြစ်ပါ။

csharp
using System;

namespace MyNamespace
{
    class MyClass
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
        }
    }
}

အရေးကြီးတဲ့ အစိတ်အပိုင်းများ

  • using System; — Console class ကိုအသုံးပြုနိုင်အောင် ခေါ်ထားပါတယ်။
  • namespace MyNamespace — code တွေကိုနာမည်ပေးထားတဲ့ area တစ်ခုထဲမှာထားပါတယ်။
  • class MyClass — C# မှာ code အများစုကို class ထဲမှာရေးပါတယ်။
  • static void Main — program စတင်တဲ့ entry point ဖြစ်ပါတယ်။
You should see
Hello World

Info

💡 Learner note

Curly braces { } တစ်ခုဖွင့်ရင် တစ်ခုအမြဲပိတ်ရပါတယ်။ C# error တော်တော်များများက brace ပျောက်တာနဲ့ semicolon မေ့တာကနေ စပါတယ်။

Real-world usage

လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ

Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။

Mini challenge

ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ

Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။

  • Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
  • Normal input နဲ့ edge case စမ်းပါ
  • Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
csharp
using System;

namespace MyNamespace
{
    class MyClass
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
        }
    }
}

ရလဒ်: Syntax & Hello World ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်

အရိပ်အမြွက် ကြည့်ရန်

Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။

Quick Quiz 1 / 3

Syntax & Hello World ရဲ့ အဓိကသဘောတရားက ဘာလဲ။

Quick Quiz 2 / 3

ဘယ်အမှားကို အရင်ဆုံးရှောင်သင့်လဲ။

Quick Quiz 3 / 3

Real project မှာ ဘယ်လိုအသုံးချသင့်လဲ။

ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ

  • Typed input → C# expression + method → CLR value / object state
  • C# syntax တွင် identifiers ကcase-sensitive ဖြစ်ပြီး statements, expressions, blocks, namespaces/types နဲ့top-level statements တို့ကို compiler ကသတ်မှတ်ထားသော grammar အတိုင်းဖတ်ပါတယ်။ Formatting က readability ကိုကူညီပေမယ့် scope ကို braces နဲ့structure ကဆုံးဖြတ်ပါတယ်။
  • Indentation ကိုscope လို့ယူဆခြင်း၊ semicolon သို့brace မကိုက်ခြင်းက misleading compiler errors ဆက်တိုက်ဖြစ်စေပါတယ်။
  • Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။

C# documentation — Microsoft Learn

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Indentation ကိုscope လို့ယူဆခြင်း၊ semicolon သို့brace မကိုက်ခြင်းက misleading compiler errors ဆက်တိုက်ဖြစ်စေပါတယ်။
  • Happy path တစ်ခု run အောင်ရုံဖြင့် code မှန်ကန်၊ maintainable နဲ့production-ready ဖြစ်ပြီဟုယူဆခြင်း။

လက်တွေ့လေ့ကျင့်ခန်း

Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။

အလုပ်ဖြစ်ကြောင်း ဒီလိုသိမယ်: Hello World

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Syntax & Hello World | Thuta Learning