Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

Namespace สำคัญใน C# ที่ควรทราบ พร้อมคำอธิบายสั้นๆ


.NET มี Namespace จำนวนมาก รวมถึง Third-party Libraries แต่มีบาง Namespace ที่ใช้บ่อยและครอบคลุม 80% ของปัญหาการเขียนโปรแกรมทั่วไป นี่คือ 20 Namespace ที่สำคัญ:

System

ประกอบด้วยประเภทพื้นฐานที่สุด: Class, Struct, Enum, Event, Interface ฯลฯ ที่ใช้บ่อยที่สุด

System.Text

คลาสสำหรับ Character Encoding (ASCII, Unicode) และการแปลงบล็อกตัวอักษรไป/มาจากบล็อกไบต์

System.Text.RegularExpressions

ฟังก์ชัน Regular Expression

System.Linq

คลาสและ Interface รองรับ LINQ (Language-Integrated Query)

System.Xml.Linq

คลาสสำหรับ LINQ to XML - XML Programming Interface ในหน่วยความจำ ที่แก้ไขเอกสาร XML ได้ง่ายและมีประสิทธิภาพ

System.Xml

รองรับการประมวลผล XML

System.Xml.Serialization

คลาสสำหรับ Serialize ออบเจกต์เป็นเอกสาร XML หรือ Stream

System.Text.Json

ประมวลผล JSON ประสิทธิภาพสูง Memory ต่ำ รองรับ UTF-8 built-in สำหรับ Serialize/Deserialize

System.Diagnostics

โต้ตอบกับ System Processes, Event Logs, Performance Counters

System.Threading

Multithreaded Programming: Synchronization (Mutex, Monitor, Interlocked, AutoResetEvent), ThreadPool, Timer

System.Threading.Tasks

ลดความซับซ้อนของ Concurrent/Asynchronous Code: Task, Task<T>, TaskFactory, TaskScheduler

System.IO

อ่าน/เขียนไฟล์และ Data Streams, รองรับไฟล์และไดเรกทอรีพื้นฐาน

System.Net

Interface โปรแกรมมิ่งง่ายสำหรับ Network Protocols

System.Net.Http

Interface สำหรับ Modern HTTP Applications

System.Net.Mail

ส่งอีเมลผ่าน SMTP Server

System.Net.Sockets

Managed Implementation ของ Windows Sockets (Winsock) ควบคุม Network ใกล้ชิด

System.Reflection

ดึงข้อมูล Assemblies, Modules, Members, Parameters จาก Metadata

System.Security

โครงสร้างพื้นฐาน CLR Security System รวม Base Classes สำหรับ Permissions

System.Security.Cryptography

บริการ Cryptography: Encoding/Decoding, Hashing, Random Number Generation, Message Authentication

System.Dynamic

รองรับ Dynamic Programming