ความแตกต่างหลัก คุณสมบัติList<T>IList<T> TypeConcrete Class (Class จริง)Interface Instantiatenew List<T>() ได้new IList<T>() ไม่ได้ InheritanceImplements IList<T>, ICollection<T>, IEnumerable<T>Extends ICollection<T>, IEnumerable<T> Featuresมี M
ความแตกต่างหลัก คุณสมบัติList<T>IList<T> TypeConcrete Class (Class จริง)Interface Instantiatenew List<T>() ได้new IList<T>() ไม่ได้ InheritanceImplements IList<T>, ICollection<T>, IEnumerable<T>Extends ICollection<T>, IEnumerable<T> Featuresมี M
Optional Parameter คืออะไร? Parameter ที่ ไม่บังคับ ต้องส่ง Argument ตอนเรียก Method มี Default Value ใน Definition ไม่ส่ง Argument → ใช้ Default Value ส่ง Argument → Override Default Value ลด Overloading Method ลงได้ วิธีสร้าง Optional Parameter 1. Default Value (Standard Way - C# 4.0+) public
Obsolete Attribute คืออะไร? Attribute ใน System namespace ใช้ทำเครื่องหมาย Class, Method, Property, Field, Delegate ว่า Deprecated/Legacy อ่านตอน Compile-time สร้าง Warning หรือ Error ให้ Developer ช่วย Migration จาก Method เก่าไปใหม่ Constructor Overloads 3 แบบ Syntaxพฤติกรรม [Obsolete]Warning
ความแตกต่างหลัก คุณสมบัติforeachParallel.ForEach ThreadSingle ThreadMultiple Threads (Thread Pool) ExecutionSequential (ลำดับ)Parallel (พร้อมกัน) Performanceช้ากว่า (CPU-bound)เร็วกว่า (Multi-core) NamespaceSystem (Built-in)System.Threading.Tasks Orderสม่ำเสมอไม่รับประกันลำดับ Exception Handlingง่า
Named Parameters คืออะไร? อนุญาตให้ระบุ Argument ด้วย ชื่อ Parameter** แทนที่จะต้องเรียงตามลำดับ** เพิ่ม Readability ของโค้ด สลับลำดับ Argument ได้ ชื่อ Parameter ต้องตรงกับ Definition Syntax MethodName(parameterName: value); ตัวอย่างโค้ด using System; namespace DemoApplication { class Dem
Dictionary ใน C# คืออะไร? Generic Collection เก็บข้อมูลแบบ Key/Value Pair Key: ไม่ซ้ำกัน (Unique), ไม่เป็น Null ได้ Value: ซ้ำได้, เป็น Null ได้ วิธี Update ค่า ใช้ Key เป็น Indexer โดยตรง: myDictionary[myKey] = myNewValue; ถ้า Key มีอยู่แล้ว → Update ค่า ถ้า Key ไม่มี → เพิ่มใหม่ (Insert) ต้อง
GUID (Globally Unique Identifier) คืออะไร? ตัวระบุเฉพาะที่ใหญ่โตมาก (128-bit) รับประกันความ Unique ทางคณิตศาสตร์ ไม่ซ้ำกันทั่วระบบ Distributed ทั้งโลก จำนวนค่าที่เป็นไปได้: 3.4 × 10³⁸ ค่า โอกาสซ้ำ: ประมาณ 1 ใน 10³⁰ (Quintillion) แม้สร้าง 10 พันล้าน GUIDs รูปแบบมาตรฐาน: 3F2504E0-4F89-11D3-9A0C-0305E
Binary Serialization คืออะไร? การแปลง Object เป็นรูปแบบ Binary (Byte Array) ที่ มนุษย์อ่านไม่ได้ เพื่อบันทึกลงไฟล์ หรือส่งผ่าน Network Deserialization คืออะไร? การแปลง Binary Data กลับเป็น Object เดิม (Human Readable) Namespace และ Class ที่ใช้ Namespace: System.Runtime.Serialization.Formatters.B
ตารางเปรียบเทียบ คุณสมบัติIEnumerableIQueryable NamespaceSystem.CollectionsSystem.Linq Lazy Loadingไม่รองรับรองรับ Query Execution (Database)Select * แล้ว Filter ใน Memory (Client-side)Select พร้อม Where ทั้งหมดที่ Server (Server-side) Extension Methods ParameterFunc<T, bool> (Delegate/Functi
เมื่อเขียนโค้ด C# แล้ว Build หรือ Run Solution จะสร้างโฟลเดอร์ 2 ตัวคือ bin และ obj ทั้งคู่เก็บ Compiled Code แต่หน้าที่ต่างกัน ทำไมต้องมี 2 โฟลเดอร์? กระบวนการ Compile ผ่าน 2 ขั้นตอน: Compiling: คอมไพล์แต่ละไฟล์เป็น Unit แยกต่างหาก → เก็บใน obj Linking: รวม Units ทั้งหมดเป็น DLL หรือ EXE เดียว →
Debug vs Release Mode ใน Visual Studio มี 2 Build Configuration: Debug Mode: ใช้สำหรับ Debug ทีละบรรทัด ไม่ Optimize โค้ด มี Symbolic Debug Info ครบ Release Mode: ใช้สำหรับ Build Production Optimize โค้ดเต็มที่ ไม่มี Debug Info #if DEBUG คืออะไร? Preprocessor Directive ที่ทำให้โค้ดภายในบล็อกทำงาน
Event ใน C# คืออะไร? Event ช่วยให้ Class หรือ Object แจ้งเตือน Class/Object อื่นๆ เมื่อมีเหตุการณ์น่าสนใจเกิดขึ้น Publisher: Class ที่ Raise Event Subscribers: Class ที่ Handle Event คุณสมบัติสำคัญ Event หนึ่งสามารถมี หลาย Subscribers ได้ Subscriber หนึ่งสามารถ Handle Event จากหลาย Publishers ได
OrderBy - เรียงลำดับข้อมูล ใช้เรียงลำดับ Array/Collection แบบ Ascending (น้อยไปมาก) หรือ Descending (มากไปน้อย) GroupBy - จัดกลุ่มข้อมูล เป็น Operator ในกลุ่ม Grouping Operators รับ Sequence แบบแบน (Flat) มาจัดกลุ่มเป็น IGrouping<TKey, TElement> ตาม Key ที่กำหนด และคืนค่ากลุ่มของ Sequence ตั
ใน C# สมาชิกของ Interface สามารถ Implement ได้ 2 แบบคือ Explicit และ Implicit Implicit Implementation คืออะไร? ไม่ต้องระบุชื่อ Interface หน้าชื่อ Member คอมไพเลอร์จะอนุมานเอง Member จะถูก Expose เป็น public และเข้าถึงได้เมื่อ Cast เป็น Concrete Type การเรียกใช้ Method ไม่ต่างจากปกติ สร้าง Object แ
DLL - Dynamic Link Library (ไลบรารีลิงก์แบบไดนามิก) หากแอสเซมบลีถูกคอมไพล์เป็น Class Library และให้ประเภท (types) เพื่อให้แอสเซมบลีอื่นๆ ใช้งาน จะมีนามสกุลไฟล์เป็น .dll (Dynamic Link Library) DLL ไม่สามารถรันได้เอง (Standalone) DLL ไม่สามารถเรียกใช้งานโดยตรงได้ เนื่องจากออกแบบมาเพื่อโหลดและรันโดยโป
Static Class Keyword: static class มีได้แค่ Static Members เท่านั้น เก็บใน Stack (Static Memory) **ไม่สามารถ** Implement Interface, Inherit Class, Pass as Parameter ไม่มี Constructor, ไม่มี Instance ไม่สามารถ Dispose ได้ Singleton Design Pattern (Creational) เป็น Object Instance เดียว (Normal Cla
Singleton Pattern (Creational) ให้ Class มี Instance เพียง **1 ตัว** ตลอด Lifetime ของ Application Implementation Guidelines Sealed Class - ป้องกัน Inheritance Private Constructor - ป้องกัน New จากภายนอก Static Instance Field - เก็บ Instance เดียว Static Property/Method - Access Point (Lazy Initial
typeof(T) Operator: ใช้กับ **Type Name** (Compile-time) Return: System.Type ไม่ต้องมี Instance Type t = typeof(string); // typeof(DemoClass) GetType() Method: เรียกบน **Object Instance** (Runtime) Return: System.Type ของ Instance จริง (Polymorphism) Defined ใน System.Object object obj = hello; T
[Flags] Attribute** บอก Compiler ว่า Enum นี้ใช้เป็น Bit Flags (Bitwise Operations) ได้ กติกา Value ต้องเป็น Power of 2: 1, 2, 4, 8, 16, 32, 64... (Bit เดียวต่อ Value) รวม Flags ด้วย Bitwise OR (|) เช็ค Flag ด้วย Bitwise AND (&) ตัวอย่าง [Flags] enum SocialMediaFlags { None = 0, Facebo
Deep Copy** = คัดลอก Object รวมถึง Object ทั้งหมดที่มันอ้างอิง (Reference Types) → ได้ Instance แยกกันสมบูรณ์ ต่างจาก Shallow Copy ที่คัดลอกแค่ Reference ตัวอย่าง Manual Deep Copy class DeepCopy { public int a = 10; } class Program { static void Main() { DeepCopy d = new DeepCop