ရိုးရိုးလေး ရှင်းပြမယ်
Operators ကို ရိုးရိုးလေးနားလည်မယ်
Operators တွေက values တွေကိုတွက်ချက်တာ၊ နှိုင်းယှဉ်တာ၊ condition စစ်တာတွေမှာ အသုံးပြုတဲ့ symbols တွေပါ။ Calculator ထဲက + , - လိုပဲ programming မှာလည်း operator တွေက logic ရဲ့ အလုပ်သမားလေးတွေပါ။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
Precedence ကိုမှတ်ဉာဏ်ပေါ်သာအားကိုးခြင်းနဲ့ `=`/`==` ရောခြင်းက logic ကိုမရှင်းစေပါ။
ဖြစ်လေ့ရှိတဲ့အမှား
Happy path တစ်ခု run အောင်ရုံဖြင့် code မှန်ကန်၊ maintainable နဲ့production-ready ဖြစ်ပြီဟုယူဆခြင်း။
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Operators တွင် precedence, associativity, operand types နဲ့short-circuit behavior ရှိပါတယ်။ `&&`/`||` ကညာဘက် expression ကိုမ run နိုင်သလို integer division, overflow နဲ့null operators များကresult ကိုသိသိသာသာပြောင်းနိုင်ပါတယ်။
- Typed input
- C# expression + method
- CLR value / object state
Operators ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
int price = 100;
int quantity = 3;
int total = price * quantity;
bool hasDiscount = total >= 300;
Console.WriteLine($"Total: {total}");
Console.WriteLine($"Discount allowed: {hasDiscount}");Operators တွင် precedence, associativity, operand types နဲ့short-circuit behavior ရှိပါတယ်။ `&&`/`||` ကညာဘက် expression ကိုမ run နိုင်သလို integer division, overflow နဲ့null operators များကresult ကိုသိသိသာသာပြောင်းနိုင်ပါတယ်။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Typed input
int price = 100;Operators တွေက values တွေကိုတွက်ချက်တာ၊ နှိုင်းယှဉ်တာ၊ condition စစ်တာတွေမှာ အသုံးပြုတဲ့ symbols တွေပါ။ Calculator ထဲက + , - လိုပဲ programming မှာလည်း operator တွေက logic ရဲ့ အလုပ်သမားလေးတွေပါ။
- C# expression + method
bool hasDiscount = total >= 300;Operators တွင် precedence, associativity, operand types နဲ့short-circuit behavior ရှိပါတယ်။ `&&`/`||` ကညာဘက် expression ကိုမ run နိုင်သလို integer division, overflow နဲ့null operators များကresult ကိုသိသိသာသာပြောင်းနိုင်ပါတယ်။
- CLR value / object state
Console.WriteLine($"Discount allowed: {hasDiscount}");Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။
- Typed input
- C# expression + method
- CLR value / object state
Success
Operators ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
Failure
Precedence ကိုမှတ်ဉာဏ်ပေါ်သာအားကိုးခြင်းနဲ့ `=`/`==` ရောခြင်းက logic ကိုမရှင်းစေပါ။
Operators တွေက values တွေကိုတွက်ချက်တာ၊ နှိုင်းယှဉ်တာ၊ condition စစ်တာတွေမှာ အသုံးပြုတဲ့ symbols တွေပါ။ Calculator ထဲက +, - လိုပဲ programming မှာလည်း operator တွေက logic ရဲ့ အလုပ်သမားလေးတွေပါ။
int price = 100;
int quantity = 3;
int total = price * quantity;
bool hasDiscount = total >= 300;
Console.WriteLine($"Total: {total}");
Console.WriteLine($"Discount allowed: {hasDiscount}");ဒီ code မှာ ဘာတွေတွေ့ရမလဲ
*က multiplication operator ဖြစ်ပြီး price နဲ့ quantity ကိုမြှောက်ပါတယ်။>=က comparison operator ဖြစ်ပြီး total က 300 ထက်ကြီး/ညီလား စစ်ပါတယ်။- Comparison result က
trueသို့မဟုတ်falseဖြစ်ပါတယ်။
Total: 300 Discount allowed: TrueInfo
🔎 Operator groups
Arithmetic: + - * / %၊ Assignment: = += -=၊ Comparison: == != > < >= <=၊ Logical: && || !
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။
- Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
- Normal input နဲ့ edge case စမ်းပါ
- Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
int price = 100;
int quantity = 3;
int total = price * quantity;
bool hasDiscount = total >= 300;
Console.WriteLine($"Total: {total}");
Console.WriteLine($"Discount allowed: {hasDiscount}");ရလဒ်: Operators ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။
Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- Typed input → C# expression + method → CLR value / object state
- Operators တွင် precedence, associativity, operand types နဲ့short-circuit behavior ရှိပါတယ်။ `&&`/`||` ကညာဘက် expression ကိုမ run နိုင်သလို integer division, overflow နဲ့null operators များကresult ကိုသိသိသာသာပြောင်းနိုင်ပါတယ်။
- Precedence ကိုမှတ်ဉာဏ်ပေါ်သာအားကိုးခြင်းနဲ့ `=`/`==` ရောခြင်းက logic ကိုမရှင်းစေပါ။
- Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။
C# documentation — Microsoft Learn