Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#
C#
  1. ตรวจสอบว่า HashSet เป็น Proper Superset ของคอลเลกชันที่ระบุใน C#

    เมธอด IsProperSupersetOf(IEnumerable<T> other) ของ HashSet<T> คืนค่า true หาก HashSet ปัจจุบันมีองค์ประกอบ ครบถ้วนของ other และมีเพิ่มเติมอีกอย่างน้อย 1 ตัว (คือ Superset แต่ไม่เท่ากัน) ตัวอย่างที่ 1: HashSet<int> Proper Superset Console.WriteLine(set1 เป็น Proper Superse

  2. ลบรายการทั้งหมดจาก ListDictionary ใน C#

    เมธอด Clear() ของ ListDictionary ใช้ลบคู่คีย์-ค่าทั้งหมด ทำให้ Count กลายเป็น 0 ตัวอย่างที่ 1: ลบรายการทั้งหมดและเปรียบเทียบ using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { ListDictionary dict1 = new List

  3. ลบออบเจ็กต์ทั้งหมดจาก Queue ใน C#

    เมธอด Clear() ของ Queue<T> ใช้ลบองค์ประกอบทั้งหมดออกจากคิว ทำให้ Count กลายเป็น 0 ตัวอย่างที่ 1: Queue<string> พื้นฐาน using System; using System.Collections.Generic; public class Demo { public static void Main() { Queue<string> queue = new Queue<string>();

  4. ดึง Enumerator เพื่อวนลูปผ่าน HybridDictionary ใน C#

    HybridDictionary ให้เมธอด GetEnumerator() คืนค่า IDictionaryEnumerator สำหรับวนลูปคู่คีย์-ค่า และรองรับ foreach กับ DictionaryEntry โดยตรง ตัวอย่างที่ 1: ใช้ foreach และ IDictionaryEnumerator using System; using System.Collections; using System.Collections.Specialized; public class Demo { publ

  5. ดึงคอลเลกชันค่าจาก ListDictionary ใน C#

    คุณสมบัติ Values ของ ListDictionary คืนค่า ICollection ที่มีค่าทั้งหมด (Values) สามารถวนลูปด้วย foreach หรือคัดลอกไปอาร์เรย์ได้ ตัวอย่างที่ 1: ดึงค่าทั้งหมดจาก ListDictionary using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Ma

  6. ดึง Enumerator เพื่อวนลูปผ่าน ListDictionary ใน C#

    ListDictionary ใน namespace System.Collections.Specialized เป็นพจนานุกรมขนาดเล็กที่ใช้ Linked List เก็บข้อมูล ให้เมธอด GetEnumerator() คืนค่า IDictionaryEnumerator สำหรับการวนลูป ตัวอย่างที่ 1: ใช้ foreach และ IDictionaryEnumerator using System; using System.Collections; using System.Collections.Sp

  7. ดึง Enumerator เพื่อวนลูปผ่าน SortedDictionary ใน C#

    SortedDictionary<TKey, TValue> เรียงลำดับคีย์อัตโนมัติ และให้เมธอด GetEnumerator() คืนค่า IDictionaryEnumerator สำหรับการวนลูปผ่านคู่คีย์-ค่า ตัวอย่างที่ 1: SortedDictionary<int, string> using System; using System.Collections; using System.Collections.Generic; public class Demo { p

  8. ดึงคอลเลกชันคีย์จาก HybridDictionary ใน C#

    คุณสมบัติ Keys ของ HybridDictionary คืนค่า ICollection ที่มีคีย์ทั้งหมด สามารถนำไปใช้กับ CopyTo เพื่อคัดลอกไปยังอาร์เรย์ หรือวนลูปด้วย foreach ได้โดยตรง ตัวอย่างที่ 1: คัดลอกคีย์ไปยังอาร์เรย์สตริง using System; using System.Collections.Specialized; public class Demo { public static void Main()

  9. ตรวจสอบว่า HybridDictionary เป็น Read-Only หรือไม่ใน C#

    คลาส HybridDictionary ใน namespace System.Collections.Specialized มีคุณสมบัติ IsReadOnly ที่คืนค่า bool เพื่อบ่งชี้ว่าพจนานุกรมนี้เป็นแบบอ่านอย่างเดียวหรือไม่ โดยปกติ HybridDictionary จะไม่เป็น Read-Except คุณสร้าง wrapper แบบ Read-Only ขึ้นมา ตัวอย่างที่ 1: ตรวจสอบคุณสมบัติต่างๆ ของ HybridDictiona

  10. วิธีดึงองค์ประกอบที่สองของ Tuple ใน C#

    ใน C# คลาส Tuple ให้คุณสมบัติ Item1, Item2, Item3 ... ขึ้นไปตามจำนวนองค์ประกอบ เพื่อเข้าถึงค่าแต่ละตำแหน่ง โดย Item2 คือองค์ประกอบที่สอง (ดัชนี 1) ตัวอย่างที่ 1: Tuple 7 องค์ประกอบ using System; public class Demo { public static void Main(string[] args) { var tuple1 = Tuple.Create(

  11. ลบองค์ประกอบที่ดัชนีที่ระบุของ Collection ใน C#

    ในการลบองค์ประกอบที่ดัชนีเฉพาะของ Collection<T> ใน C# สามารถใช้เมธอด RemoveAt(index) ได้ โดยดัชนีเริ่มต้นที่ 0 ตัวอย่างที่ 1: ลบองค์ประกอบที่ดัชนี 3 using System; using System.Collections.ObjectModel; public class Demo { public static void Main() { Collection<string> co

  12. วิธีลบสมาชิกใน HashSet ตามเงื่อนไข Predicate ใน C#

    บทความนี้สาธิตวิธีการลบสมาชิก (elements) ใน HashSet<T> ที่ตรงกับเงื่อนไขที่กำหนดโดย Predicate<T> โดยใช้ method RemoveWhere(Predicate<T> match) ตัวอย่างที่ 1: ลบค่า 100 using System; using System.Collections.Generic; public class Demo { private static bool Demo(int i) {

  13. วิธีลบสมาชิกใน SortedSet ที่ตรงกับเงื่อนไข Predicate ใน C#

    บทความนี้สาธิตวิธีการลบสมาชิก (elements) ใน SortedSet<T> ที่ตรงกับเงื่อนไขที่กำหนดโดย Predicate<T> โดยใช้ method RemoveWhere(Predicate<T> match) ตัวอย่างที่ 1: ลบตัวเลขที่หาร 10 ลงตัว using System; using System.Collections.Generic; public class Demo { private static bool Demo

  14. วิธีดึงหรือตั้งค่าค่าที่เกี่ยวข้องกับคีย์ใน ListDictionary ใน C#

    บทความนี้สาธิตวิธีการดึง (get) และตั้งค่า (set) ค่าที่เกี่ยวข้องกับคีย์ที่ระบุใน ListDictionary โดยใช้ indexer [key] ตัวอย่างที่ 1: ดึงค่าจากคีย์ C using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { ListDict

  15. วิธีตรวจสอบว่า StringCollection สองตัวเท่ากันหรือไม่ใน C#

    บทความนี้สาธิตวิธีการตรวจสอบว่า StringCollection สองตัวเท่ากันหรือไม่ โดยใช้ method Equals(object obj) ตัวอย่างที่ 1: เปรียบเทียบ StringCollection สองตัวที่มีข้อมูลเหมือนกัน using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCo

  16. วิธีตรวจสอบว่า StringDictionary สองตัวเท่ากันหรือไม่ใน C#

    บทความนี้สาธิตวิธีการตรวจสอบว่า StringDictionary สองตัวเท่ากันหรือไม่ โดยใช้ method Equals(object obj) ตัวอย่างที่ 1: เปรียบเทียบ Dictionary 3 ตัว using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringDictionary strDict1 = new Str

  17. วิธีดึงหรือตั้งค่าค่าที่เกี่ยวข้องกับคีย์ใน SortedList ใน C#

    บทความนี้สาธิตวิธีการดึง (get) และตั้งค่า (set) ค่าที่เกี่ยวข้องกับคีย์ที่ระบุใน SortedList โดยใช้ indexer [key] ตัวอย่างที่ 1: ดึงและตั้งค่าผ่าน Indexer using System; using System.Collections; public class Demo { public static void Main() { SortedList list = new SortedList();

  18. วิธีดึงออบเจ็กต์ที่จุดเริ่มต้นของ Queue แบบ Peek ใน C#

    บทความนี้สาธิตวิธีการดูออบเจ็กต์ที่จุดเริ่มต้น (front) ของ Queue<T> โดยไม่ลบออก โดยใช้ method Peek() ตัวอย่างที่ 1: Peek คิว 7 รายการ using System; using System.Collections.Generic; public class Demo { public static void Main() { Queue<string> queue = new Queue<strin

  19. วิธีลบรายการตามคีย์ที่ระบุจาก OrderedDictionary ใน C#

    บทความนี้สาธิตวิธีการลบรายการ (entry) ตามคีย์ที่ระบุจาก OrderedDictionary โดยใช้ method Remove(object key) ตัวอย่างที่ 1: ลบคีย์ E using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { OrderedDictionary dict =

  20. วิธีลบรายการตามคีย์ที่ระบุจาก StringDictionary ใน C#

    บทความนี้สาธิตวิธีการลบรายการ (entry) ตามคีย์ที่ระบุจาก StringDictionary โดยใช้ method Remove(string key) ตัวอย่างที่ 1: ลบคีย์ D และแสดงก่อนหลัง using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { StringDict

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:104/134  20-คอมพิวเตอร์/Page Goto:1 98 99 100 101 102 103 104 105 106 107 108 109 110