Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#
C#
  1. วิธีตรวจสอบว่า Thread ยังทำงานอยู่หรือไม่ใน C#

    Thread.IsAlive - ตรวจสอบสถานะ Thread Thread.IsAlive (Property) คืนค่า true ถ้า Thread เริ่มทำงานแล้ว (Start()) และยังไม่จบ (ยังไม่ Return จาก Method หรือ Abort) สถานะ Thread (ThreadState) StateคำอธิบายIsAlive Unstartedยังไม่ Start()False RunningกำลังทำงานTrue WaitSleepJoin

  2. จำนวน Elements ใน BitArray C#

    BitArray และ Property Count BitArray (ใน System.Collections) จัดการ Array ของ Bit (Boolean) ใช้ Property Count ดึงจำนวน Elements (Bits) ตัวอย่างที่ 1: BitArray พื้นฐาน และ Bitwise OR using System; using System.Collections; public class Demo { public static void Main() { BitArray a

  3. การค้นหา Index ของ Object ใน Collection ใน C#

    การค้นหา Index ใน Collection (StringCollection) StringCollection (ใน System.Collections.Specialized) เป็นคอลเลกชันสำหรับ String มีเมธอด IndexOf() ค้นหา Index ของ Object ตัวอย่างที่ 1: StringCollection พื้นฐาน using System; using System.Collections.Specialized; public class Demo { public stati

  4. ค้นหา Index สุดท้ายที่ Match เงื่อนไขใน List C# (FindLastIndex)

    List.FindLastIndex Method ค้นหา Element ที่ Match Predicate จากท้ายมาหน้า คืนค่า Zero-based Index (หาไม่เจอ = -1) Overloads // 1. Search ทั้ง List int FindLastIndex(Predicate match) // 2. Search จาก Index ถึงต้น int FindLastIndex(int startIndex, Predicate match) // 3. Search ใน Range int FindLas

  5. หาจำนวน Elements ใน Array มิติที่กำหนดใน C#

    Array Methods สำหรับ Dimension Info Methodคืนค่าคำอธิบาย GetLength(int dimension)intจำนวน Elements ใน Dimension ที่ระบุ (0-based) GetLongLength(int dimension)long 2^31) GetLowerBound(int dimension)intLower Bound ของ Dimension (ปกติเป็น 0) GetUpperBound(int dimension)intUpper Bound ของ Dimension Ran

  6. ความแตกต่างระหว่าง var และ dynamic ใน C#

    ความแตกต่างหลัก: Static vs Dynamic Typing คุณสมบัติvar (Implicitly Typed)dynamic Type ResolutionCompile-time (Static)Runtime (Dynamic) Type Inferenceจาก Initializer Expressionจาก Runtime Value Initializationบังคับ ต้อง Initialize ทันทีไม่บังคับ (สามารถเป็น null/เปลี่ยน Type ได้) Type SafetyFull Com

  7. ความแตกต่างระหว่าง Abstract Class และ Interface ใน C#

    ความแตกต่างหลัก คุณสมบัติAbstract ClassInterface Implementationมีได้ทั้ง Abstract และ Concrete MembersC# 8-: Signature เท่านั้น C# 8+: Default Implementation ได้ InheritanceSingle Inheritance (class A : Base)Multiple Implementation (class A : I1, I2) Constructorมีได้ (Protected/Public)ไม่มี Fields/

  8. การรันโค้ด C# บน Linux ด้วย Mono และ .NET Core

    การรัน C# บน Linux: ทุกยุค 1. Mono (Legacy/Cross-Platform Framework) Mono เป็น Open-source Implementation ของ .NET Framework ทำงานบน Linux, macOS, Windows รองรับ Windows Forms, ASP.NET, ADO.NET, LINQ Compiler: mcs (Mono C# Compiler) Runtime: mono command Status: Maintenance Mode, แทนที่ด้วย .NET C

  9. ความแตกต่างระหว่าง readonly และ const ใน C#

    ความแตกต่างหลัก คุณสมบัติconstreadonly Evaluation TimeCompile-time ConstantRuntime Constant Value Assignmentต้อง Assign ตอน DeclarationAssign ได้ใน Declaration หรือ Constructor Modifiableไม่สามารถเปลี่ยนได้เลยเปลี่ยนได้ใน Constructor (Instance) ScopeImplicitly StaticInstance หรือ Static Type Restri

  10. ความแตกต่างระหว่าง out และ ref ใน C#

    ความแตกต่างสรุป คุณสมบัติrefout ทิศทางข้อมูลIn/Out (Two-way)Out Only (One-way) Initialization ก่อนส่งบังคับ ต้อง Initialize ก่อนไม่ต้อง Initialize Assignment ใน MethodOptional (อ่าน/เขียนได้)บังคับ ต้อง Assign ทุก Path วัตถุประสงค์Modify Existing VariableReturn Additional Values Overload Resolution

  11. ความแตกต่างระหว่าง Class และ Struct ใน C#

    ความแตกต่างหลัก: Reference Type vs Value Type คุณสมบัติClass (Reference Type)Struct (Value Type) Memory AllocationHeap (Managed Heap)Stack (หรือ Inline ใน Containing Type) AssignmentCopy Reference (Point to Same Object)Copy Value (Deep Copy) Nullสามารถเป็น Null ได้ไม่สามารถเป็น Null ได้ (Nullable S

  12. ความแตกต่างระหว่าง Method Overriding และ Method Hiding ใน C#

    Method Overriding vs Method Hiding ทั้งคู่คือการ นิยามใหม่ Method ของ Base Class ใน Derived Class แต่กลไกและพฤติกรรมต่างกัน ด้านMethod OverridingMethod Hiding (Shadowing) Keywordvirtual (Base) + override (Derived)new (Derived) Polymorphism✅ รองรับ (Runtime Polymorphism)❌ ไม่รองรับ (Compile-time Bi

  13. ตัวแปร Dynamic ใน C# คืออะไร ใช้เมื่อไหร่

    dynamic Keyword คืออะไร? บอก Compiler: Skip Compile-time Type Checking, ตรวจสอบตอน Runtime แทน Static Typed Language (C#) → Dynamic Behavior Type Resolution เลื่อนไป Runtime (DLR - Dynamic Language Runtime) Syntax Errors → Runtime Errors (Exception) IntelliSense ไม่ทำงาน ตัวอย่างพื้นฐาน using Sy

  14. การใช้งานคำสั่ง is ใน C#

    is Keyword คืออะไร? ใช้ตรวจสอบว่า Object สามารถ Cast เป็น Type ที่กำหนดได้หรือไม่ คืนค่า bool Type Testing: obj is Type Pattern Matching (C# 7+): obj is Type variable Constant Pattern: obj is null, obj is 5 Relational Patterns (C# 9+): 0 ตัวอย่างพื้นฐาน: Type Testing using System; class Employ

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:120/134  20-คอมพิวเตอร์/Page Goto:1 114 115 116 117 118 119 120 121 122 123 124 125 126