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

    BinaryReader Class ใน C# BinaryReader อ่าน Primitive Types จาก Stream แบบ Binary จำเป็นต้องรู้ลำดับและชนิดข้อมูลที่เขียนไว้ (Paired กับ BinaryWriter) Constructor new BinaryReader(Stream input) new BinaryReader(Stream input, Encoding encoding) new BinaryReader(Stream input, Encoding encoding, bool

  2. คุณสมบัติ Item ของ BitArray Class ใน C#

    คุณสมบัติ Item ของ BitArray ใน C# BitArray แทนอาร์เรย์ของ Bit (Boolean Values) คุณสมบัติ Item[int index] (Indexer) ใช้ Get/Set ค่า Bit ที่ Index ที่กำหนด ไวยากรณ์ // Get bool value = bitArray[index]; // Set bitArray[index] = true; // หรือ false ตัวอย่างการใช้งาน using System; using System.Coll

  3. การใช้ C# BinaryWriter Class

    BinaryWriter Class ใน C# BinaryWriter เขียน Primitive Types (int, double, string, bool, etc.) เป็น Binary Format ลง Stream ใช้ร่วมกับ BinaryReader สำหรับอ่านกลับ Constructor new BinaryWriter(Stream output) new BinaryWriter(Stream output, Encoding encoding) new BinaryWriter(Stream output, Encoding

  4. Access Specifiers ใน C#.NET

    Access Specifiers (Access Modifiers) ใน C#.NET ควบคุม Visibility (ความมองเห็น) ของ Type และ Member ระหว่าง Assembly และ Derived Classes 6 Access Modifiers Modifierภายใน ClassDerived Class (Same Assembly)Other Class (Same Assembly)Derived Class (Other Assembly)Other Class (Other Assembly) public✓✓

  5. การใช้ C# FileStream Class

    FileStream Class ใน C# FileStream ให้ Stream สำหรับอ่าน/เขียนไฟล์ในระดับ Byte รองรับ Both Synchronous และ Asynchronous Operations อยู่ใน System.IO Constructor สำคัญ // พื้นฐาน new FileStream(path, FileMode) // พร้อม Access และ Share new FileStream(path, FileMode, FileAccess, FileShare) // Async

  6. วิธีคำนวณขนาดโฟลเดอร์ (Folder Size) ใน C#

    ใช้ Directory.EnumerateFiles() และ LINQ Sum() คำนวณขนาดไฟล์ทั้งหมดรวม Subdirectories โค้ดหลัก file.Length); โค้ดตัวอย่างเต็ม = 1024 && i < units.Length - 1) { size /= 1024; i++; } return ${size:0.##} {units[i]}; } } เมธอด Directory อื่นๆ ที่มีป

  7. คำนวณกำลังด้วย Recursion ใน C#

    การคำนวณกำลังด้วย Recursion (การเรียกซ้ำ) ใน C# Recursive Function เรียกตัวเองจนถึง Base Case แล้วคืนค่ากลับมาทีละขั้น หลักการ Recursion สำหรับ Power power(n, p) = n * power(n, p-1) // Recursive Case power(n, 0) = 1 // Base Case ตัวอย่างโค้ด using System; public class Demo

  8. เรียก Custom Method ใน C#

    การสร้างและเรียก Custom Method (เมธอดกำหนดเอง) ใน C# Custom Method คือ เมธอดที่นักพัฒนาสร้างขึ้นเองเพื่อทำหน้าที่เฉพาะเจาะจง ช่วยให้โค้ดเป็น Modular, Reusable, Readable ไวยากรณ์การประกาศ (Parameter List) { // Method Body return value; // ถ้าไม่ใช่ void } ตัวอย่าง: ตรวจสอบ Palindrome แบ

  9. คำนวณกำลังเศษส่วน (Fractional Power) ใน C#

    การคำนวณกำลังเศษส่วน (Fractional Power) ใน C# ใช้ Method Math.Pow(double base, double exponent) รองรับ Exponent เป็นทศนิยม (Fractional) ได้โดยตรง ตัวอย่างพื้นฐาน using System; class Program { static void Main() { // 5 ยกกำลัง 3.7 double result = Math.Pow(5, 3.7); C

  10. ส่ง Parameter ให้ Method ใน C#

    การส่ง Parameter ให้ Method ใน C# C# รองรับ 4 รูปแบบการส่งพารามิเตอร์ 1. Pass by Value (Default) Copy ค่าของ Variable ไปให้ Parameter การเปลี่ยนแปลงใน Method ไม่ส่งผล ต่อตัวแปรต้นทาง Value Types: Copy ค่า, Reference Types: Copy Reference (แต่อ็อบเจกต์เดียวกัน) ตัวอย่าง using System; namespace

  11. Pointer ใน C# คืออะไร

    Pointer (ตัวชี้) ใน C# Pointer คือตัวแปรที่เก็บ Address (ที่อยู่หน่วยความจำ) ของตัวแปรอีกตัวหนึ่ง ใช้ใน unsafe Context เท่านั้น ไวยากรณ์ type* variableName; // ตัวอย่าง int* p; // Pointer to int double* d; // Pointer to double Operators หลัก Operatorชื่อฟังก์ชัน &Address-ofได้ Address ข

  12. ส่ง Pointer เป็น Parameter ใน C#

    การส่ง Pointer เป็น Parameter ใน C# (Unsafe Code) C# รองรับ Pointer ใน unsafe Context เท่านั้น ใช้สำหรับ Interop, Performance Critical, หรือ Low-level Memory Manipulation ข้อกำหนด Project Properties → Build → Allow unsafe code ✓ ใช้คีย์เวิร์ด unsafe บน Method/Class/Block Compile ด้วย /unsafe flag

  13. Method Overloading ใน C#

    Method Overloading ใน C# Method Overloading คือการประกาศเมธอดหลายตัวที่มี ชื่อเดียวกัน แต่ Parameter List ต่างกัน (จำนวน, ชนิด, ลำดับ) ใน Class เดียวกัน วิธี Overload ได้ 2 แบบ จำนวนพารามิเตอร์ต่างกัน ชนิดข้อมูลพารามิเตอร์ต่างกัน Return Type เพียงอย่างเดียว Overload ไม่ได้ ตัวอย่าง: จำนวนพารามิเ

  14. Inheritance (การสืบทอด) ใน C#

    Inheritance (การสืบทอด) ใน C# Inheritance ช่วยให้สร้าง Class ใหม่ (Derived/Child) จาก Class เดิม (Base/Parent) ได้ โดยสืบทอด Fields, Methods, Properties มาใช้งาน/ขยาย/แก้ไข (Override) ได้ คุณสมบัติหลัก Single Inheritance: Class เดียวสืบทอดจาก Base Class เดียว (แต่ Implement Interface ได้หลายตัว) A

  15. ส่วนประกอบหลักของโปรแกรม C#

    ส่วนประกอบหลักของโปรแกรม C# โครงสร้างพื้นฐานของโปรแกรม C# ประกอบด้วย 7 ส่วนหลัก 7 ส่วนประกอบ Namespace Declaration - กลุ่มคลาสที่เกี่ยวข้อง (namespace Demo) Class Declaration - แม่แบบของอ็อบเจกต์ (class Program) Class Methods - พฤติกรรมของคลาส (Main, Print, etc.) Class Attributes/Fields - ข้อมูล/ส

  16. เมธอดและ Property ของ Thread Class ใน C#

    Thread Class ใน C#: Properties และ Methods System.Threading.Thread คลาสหลักสำหรับจัดการ Thread แบบ Manual (Low-level) ปัจจุบันแนะนำให้ใช้ Task/ThreadPool แทน Properties สำคัญ Propertyคำอธิบาย CurrentThreadStatic: ได้ Thread ปัจจุบัน CurrentContextContext ที่ Thread กำลัง Execute CurrentCultureCul

  17. Conditional Pre-processor Directive ใน C#

    Conditional Pre-processor Directives ใน C# Pre-processor Directives เริ่มต้นด้วย # ใช้ควบคุมการคอมไพล์ (Conditional Compilation) ไม่ใช่ Statement ปกติ (ไม่มี Semicolon) Directives หลัก Directiveคำอธิบาย #define SYMBOLกำหนด Symbol (Conditional Compilation Symbol) #undef SYMBOLยกเลิก Symbol #if SYM

  18. Compile-time Polymorphism ใน C#

    Compile-time Polymorphism (Static Polymorphism) ใน C# Static Polymorphism = การตัดสินใจเรียกเมธอดใดในขณะ Compile-time (Early Binding) ทำได้ 2 วิธี: Method Overloading และ Operator Overloading 1. Method Overloading (Function Overloading) หลายเมธอดชื่อเดียวกัน Signature ต่างกัน (พารามิเตอร์ต่างชนิด/จ

  19. Ternary Operator / Conditional Operator ใน C#

    Ternary Operator (Conditional Operator) ใน C# Ternary Operator ? : เป็น Operator เติมที่รับ 3 Operand: condition ? trueExpression : falseExpression ใช้แทน if-else แบบสั้นๆ ไวยากรณ์ variable = condition ? valueIfTrue : valueIfFalse; ตัวอย่างพื้นฐาน ค่า 20 b = (a == 10) ? 20 : 30;

  20. Composition ใน C# คืออะไร

    Composition (การประกอบ) ใน C# Composition เป็นรูปแบบความสัมพันธ์ Has-A แบบ Strong Ownership: Parent ควบคุม Lifetime ของ Child หาก Parent ถูกทำลาย Child ก็จะถูกทำลายไปด้วย ตัวอย่าง: รถยนต์และเครื่องยนต์ Console.WriteLine(Engine stopped); } public class Car { // Composition: Car เป็นเจ้าของ Eng

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:17/134  20-คอมพิวเตอร์/Page Goto:1 11 12 13 14 15 16 17 18 19 20 21 22 23