Thuta Learning
C#
BasicProgrammingအခြေခံ

Operators

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

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

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

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

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 ကိုသိသိသာသာပြောင်းနိုင်ပါတယ်။

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

Operators ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်

အဓိက Syntax / Pattern

csharp
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 ကို အဆင့်လိုက်ဖတ်မယ်

  1. Typed inputint price = 100;

    Operators တွေက values တွေကိုတွက်ချက်တာ၊ နှိုင်းယှဉ်တာ၊ condition စစ်တာတွေမှာ အသုံးပြုတဲ့ symbols တွေပါ။ Calculator ထဲက + , - လိုပဲ programming မှာလည်း operator တွေက logic ရဲ့ အလုပ်သမားလေးတွေပါ။

  2. C# expression + methodbool hasDiscount = total >= 300;

    Operators တွင် precedence, associativity, operand types နဲ့short-circuit behavior ရှိပါတယ်။ `&&`/`||` ကညာဘက် expression ကိုမ run နိုင်သလို integer division, overflow နဲ့null operators များကresult ကိုသိသိသာသာပြောင်းနိုင်ပါတယ်။

  3. CLR value / object stateConsole.WriteLine($"Discount allowed: {hasDiscount}");

    Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။

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

Success

Operators ရဲ့core concept နဲ့runtime behavior ကိုရှင်းပြနိုင်ရန်

Failure

Precedence ကိုမှတ်ဉာဏ်ပေါ်သာအားကိုးခြင်းနဲ့ `=`/`==` ရောခြင်းက logic ကိုမရှင်းစေပါ။

Operators တွေက values တွေကိုတွက်ချက်တာ၊ နှိုင်းယှဉ်တာ၊ condition စစ်တာတွေမှာ အသုံးပြုတဲ့ symbols တွေပါ။ Calculator ထဲက +, - လိုပဲ programming မှာလည်း operator တွေက logic ရဲ့ အလုပ်သမားလေးတွေပါ။

csharp
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 ဖြစ်ပါတယ်။
You should see
Total: 300 Discount allowed: True

Info

🔎 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 ကိုခန့်မှန်းပါ
csharp
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

Operators ရဲ့ အဓိကသဘောတရားက ဘာလဲ။

Quick Quiz 2 / 3

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

Quick Quiz 3 / 3

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

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

  • 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

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

  • Precedence ကိုမှတ်ဉာဏ်ပေါ်သာအားကိုးခြင်းနဲ့ `=`/`==` ရောခြင်းက logic ကိုမရှင်းစေပါ။
  • Happy path တစ်ခု run အောင်ရုံဖြင့် code မှန်ကန်၊ maintainable နဲ့production-ready ဖြစ်ပြီဟုယူဆခြင်း။

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

Parentheses မပါ/ပါ expression, integer/decimal division နဲ့short-circuit guard ကိုside-by-side စမ်းပြီး output ကိုမ run မီခန့်မှန်းပါ။

အလုပ်ဖြစ်ကြောင်း ဒီလိုသိမယ်: Total: 300 Discount allowed: True

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

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

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

Operators | Thuta Learning