C# သည် Microsoft မှ ဖန်တီးထားသော modern, object-oriented, type-safe programming language တစ်ခုဖြစ်ပါတယ်။ Type-safe ဆိုတာ variable တစ်ခုမှာ ဘယ်လို data ထည့်မယ်ဆိုတာကို compiler က သေချာစစ်ပေးတာပါ။ ဥပမာ int ထဲကို စာသားထည့်မယ်ဆိုရင် run မလုပ်ခင်တည်းက သတိပေးပေးပါတယ်။
csharp
// C# program တစ်ခုက class ထဲက Main method မှစတင်အလုပ်လုပ်ပါတယ်။
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello from C#!");
}
}
}ဒီ code က ဘာလုပ်တာလဲ
using System;က Console လို built-in tools တွေသုံးနိုင်အောင် ခေါ်ထားတာပါ။namespaceက code တွေကို folder စနစ်လို အုပ်စုခွဲပြီး စနစ်တကျထားပေးပါတယ်။class Programထဲမှာ program ရဲ့ logic တွေကိုရေးပါတယ်။Mainmethod က app စတင်အလုပ်လုပ်တဲ့နေရာပါ။Console.WriteLine()က terminal ထဲကိုစာကြောင်းတစ်ကြောင်းထုတ်ပြပါတယ်။
You should see
Hello from C#!Info
🔎 သတိထားရန်
C# မှာ statement အများစုကို semicolon ; နဲ့အဆုံးသတ်ရပါတယ်။ မေ့သွားရင် compiler က ချက်ချင်းငြင်းပါလိမ့်မယ်။