ภาพรวม
Visual Studio เป็น IDE หลักสำหรับพัฒนา C# บน Windows รองรับ .NET Framework, .NET Core, .NET 5+ พร้อมเครื่องมือครบครัน
คุณสมบัติหลักของ Visual Studio
- IntelliSense: Code completion, parameter info, quick info
- Debugger: Breakpoints, watch windows, call stack, immediate window
- Refactoring: Rename, extract method, inline, आदि
- Git Integration: Built-in source control
- NuGet Package Manager: จัดการ dependencies
- Unit Test Explorer: รัน/ดูผล Test ทั้ง solution
- Live Share: Real-time collaboration
ขั้นตอนสร้างและรัน Console App
- เปิด Visual Studio → Create a new project
- ค้นหา "Console App" → เลือก Console App (C#) ที่มี Tag
.NET Coreหรือ.NET 6/7/8 - Click Next
- ตั้งชื่อ Project (เช่น
HelloWorld) → Next - เลือก Target Framework (แนะนำ .NET 8.0 LTS) → Create
- โค้ดจะปรากฏใน
Program.cs - กด F5 (Start Debugging) หรือ Ctrl+F5 (Start Without Debugging)
โค้ด Hello World (.NET 6+ Top-level Statements)
// Program.cs
Console.WriteLine("Hello, World!");
โครงสร้างโปรเจกต์
HelloWorld/
├── HelloWorld.csproj # Project file (SDK-style)
├── Program.cs # Entry point
├── obj/ # Build intermediates
└── bin/ # Build outputs
└── Debug/net8.0/
├── HelloWorld.exe
├── HelloWorld.dll
└── HelloWorld.pdb
Command Line (dotnet CLI)
# สร้างโปรเจกต์ใหม่
dotnet new console -n HelloWorld
cd HelloWorld
# รัน
dotnet run
# Build
dotnet build
# Build Release
dotnet build -c Release
# Publish (Self-contained)
dotnet publish -c Release -r win-x64 --self-contained true
Visual Studio Editions
| Edition | Price | Target |
|---|---|---|
| Community | Free | Individual, Open Source, Small Teams |
| Professional | Paid | Professional Developers |
| Enterprise | Paid | Large Teams, Advanced Testing/Architecture |
Alternative IDEs บน Windows
- VS Code + C# Dev Kit Extension (Lightweight, Cross-platform)
- JetBrains Rider (Paid, Cross-platform, Excellent Refactoring)
- Visual Studio Code + OmniSharp (Free, Open Source)