ရိုးရိုးလေး ရှင်းပြမယ်
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 ကဆုံးဖြတ်ပါတယ်။
- Typed input
- C# expression + method
- CLR value / object state
Syntax & Hello World ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
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 ကို အဆင့်လိုက်ဖတ်မယ်
- Typed input
using System;C# program တစ်ခုရဲ့ အခြေခံတည်ဆောက်ပုံမှာ using , namespace , class , Main method တို့ ပါဝင်ပါတယ်။ အစမှာ syntax နည်းနည်းများတယ်လို့ထင်ရပေမယ့် တစ်ခါနားလည်သွားရင် project တွေကို စနစ်တကျတည်ဆောက်နိုင်စေတဲ့ အခြေခံအုတ်မြစ်ပါ။
- C# expression + method
static void Main(string[] args)C# syntax တွင် identifiers ကcase-sensitive ဖြစ်ပြီး statements, expressions, blocks, namespaces/types နဲ့top-level statements တို့ကို compiler ကသတ်မှတ်ထားသော grammar အတိုင်းဖတ်ပါတယ်။ Formatting က readability ကိုကူညီပေမယ့် scope ကို braces နဲ့structure ကဆုံးဖြတ်ပါတယ်။
- CLR value / object state
}Hello World ကို top-level statements ပုံစံနဲ့`Program.Main` ပုံစံနှစ်မျိုးရေးပြီး entry point တစ်ခုသာရှိရကြောင်းစမ်းပါ။
- Typed input
- C# expression + method
- 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 တွေကို စနစ်တကျတည်ဆောက်နိုင်စေတဲ့ အခြေခံအုတ်မြစ်ပါ။
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 ဖြစ်ပါတယ်။
Hello WorldInfo
💡 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 ကိုခန့်မှန်းပါ
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
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- 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