Operators(Part -2)
1. Operator အမျိုးအစားများ C# Basic မှာ အဓိကလေ့လာမယ့် Operators များက— Arithmetic Operators Assignment Operators Increment and Decrement Operators Comparison Operators Logical Operators Unary Operators Ternary Operator Null-coalescing Operator တို့ဖြစ်ပါတယ်။
1. Operator အမျိုးအစားများ
C# Basic မှာ အဓိကလေ့လာမယ့် Operators များက—
- Arithmetic Operators
- Assignment Operators
- Increment and Decrement Operators
- Comparison Operators
- Logical Operators
- Unary Operators
- Ternary Operator
- Null-coalescing Operator
တို့ဖြစ်ပါတယ်။
Arithmetic Operators
2. Arithmetic Operators ဆိုတာဘာလဲ
Arithmetic Operators တွေကို Number များ ပေါင်း၊ နုတ်၊ မြှောက်၊ စားခြင်းနဲ့ အကြွင်းရှာခြင်းတို့အတွက် အသုံးပြုပါတယ်။
| Operator | အဓိပ္ပာယ် | နမူနာ |
|---|---|---|
+ | ပေါင်းခြင်း | 10 + 5 |
- | နုတ်ခြင်း | 10 - 5 |
* | မြှောက်ခြင်း | 10 * 5 |
/ | စားခြင်း | 10 / 5 |
% | အကြွင်းရှာခြင်း | 10 % 3 |
3. Addition Operator (+)
+ Operator ကို Number များ ပေါင်းဖို့ အသုံးပြုပါတယ်။
int firstNumber = 10; int secondNumber = 20; int result = firstNumber + secondNumber; Console.WriteLine(result);
Output—
30
နောက်ထပ်နမူနာ—
decimal unitPrice = 15000m; decimal deliveryFee = 2000m; decimal totalAmount = unitPrice + deliveryFee; Console.WriteLine($"Total Amount: {totalAmount}");
Output—
Total Amount: 17000
4. String Concatenation
+ Operator ကို String များ ဆက်စပ်ဖို့လည်း အသုံးပြုနိုင်ပါတယ်။
string firstName = "Aung"; string lastName = "Aung"; string fullName = firstName + " " + lastName; Console.WriteLine(fullName);
Output—
Aung Aung
Number ပေါင်းခြင်းနဲ့ String ဆက်ခြင်းကို ခွဲခြားနားလည်ဖို့ အရေးကြီးပါတယ်။
Console.WriteLine(10 + 20); Console.WriteLine("10" + "20");
Output—
30 1020
ပထမစာကြောင်းမှာ Integer နှစ်ခုကို ပေါင်းထားပါတယ်။ ဒုတိယစာကြောင်းမှာ String နှစ်ခုကို ဆက်ထားပါတယ်။