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

    ภาพรวม ArrayList.CopyTo(Array array, int index) คัดลอกทุกข้อมูลจาก ArrayList ไปยังอาร์เรย์ปลายทาง เริ่มที่ดัชนีที่ระบุ ตัวอย่างที่ 1: คัดลอกสตริงไปอาร์เรย์ขนาด 6 เริ่มดัชนี 0 (เขียนทับทั้งหมด) using System; using System.Collections; public class Demo { public static void Main() { A

  2. การสร้าง Stack ใน C#

    ภาพรวม Stack<T> เป็นโครงสร้างข้อมูลแบบ LIFO (Last In, First Out) ใช้ Push() เพิ่มข้อมูล, Pop() ดึงข้อมูลออก, Peek() ดูข้อมูลบนสุด, และ Contains() ตรวจสอบว่ามีค่าหรือไม่ ตัวอย่างที่ 1: สร้าง Stack จำนวนเต็มและใช้งานพื้นฐาน using System; using System.Collections.Generic; public class Demo {

  3. การดึงช่วงย่อย (Subset) จาก SortedSet ใน C#

    ภาพรวม SortedSet<T>.GetViewBetween(T lower, T upper) คืนค่า view ของช่วงข้อมูลระหว่างค่าต่ำสุดและสูงสุด (inclusive) โดยไม่ต้องคัดลอกข้อมูลจริง ตัวอย่างที่ 1: ดึงช่วงย่อยจาก SortedSet สตริง using System; using System.Collections.Generic; public class Demo { public static void Main() {

  4. การคัดลอกข้อมูล Hashtable ไปยังอาร์เรย์ใน C#

    ภาพรวม Hashtable.CopyTo(Array array, int index) คัดลอกคู่คีย์/ค่าเป็น DictionaryEntry ไปยังอาร์เรย์ปลายทาง ตั้งแต่ดัชนีที่ระบุ ตัวอย่างที่ 1: คัดลอกไปอาร์เรย์ขนาดเท่าจำนวนข้อมูล เริ่มดัชนี 0 using System; using System.Collections; public class Demo { public static void Main() { Has

  5. การคัดลอกข้อมูล HybridDictionary ไปยังอาร์เรย์ใน C#

    ภาพรวม HybridDictionary.CopyTo(Array array, int index) คัดลอกคู่คีย์/ค่าเป็น DictionaryEntry ไปยังอาร์เรย์ปลายทาง ตั้งแต่ดัชนีที่ระบุ ตัวอย่างที่ 1: คัดลอกไปอาร์เรย์ขนาด 10 เริ่มดัชนี 2 using System; using System.Collections; using System.Collections.Specialized; public class Demo { public sta

  6. การคัดลอกข้อมูล SortedList ไปยัง Array Object ใน C#

    ภาพรวม เมธอด CopyTo(Array array, int index) ของ SortedList ใช้คัดลอกข้อมูล (DictionaryEntry) ไปยังอาร์เรย์ตั้งแต่ดัชนีที่ระบุ ตัวอย่างที่ 1: คัดลอกไปยังอาร์เรย์ขนาด 10 เริ่มดัชนี 2 using System; using System.Collections; public class Demo { public static void Main(String[] args) {

  7. การนับจำนวนคู่คีย์/ค่าใน HybridDictionary ใน C#

    ภาพรวม HybridDictionary ใน namespace System.Collections.Specialized มี property Count สำหรับดูจำนวนคู่คีย์/ค่า รองรับการเพิ่ม ลบ และล้างข้อมูล ตัวอย่างที่ 1: นับจำนวนคู่ใน HybridDictionary หลายตัว using System; using System.Collections; using System.Collections.Specialized; public class Demo {

  8. การสร้าง Wrapper แบบ Synchronized สำหรับ SortedList ใน C#

    ภาพรวม SortedList.Synchronized() ใช้สร้าง wrapper แบบ thread-safe สำหรับ SortedList ซึ่งคืนค่า instance ใหม่ที่มี property IsSynchronized เป็น true ตัวอย่างที่ 1: สร้าง SortedList และ wrapper แบบ synchronized using System; using System.Collections; public class Demo { public static void Main()

  9. การสร้าง StringBuilder ด้วยความจุที่กำหนดใน C#

    ภาพรวม StringBuilder ใน C# มีคอนสตรัคเตอร์หลายแบบ รองรับการกำหนดความจุเริ่มต้น (Capacity) ซึ่งช่วยเพิ่มประสิทธิภาพเมื่อทราบขนาดข้อมูลล่วงหน้า ตัวอย่างที่ 1: สร้าง StringBuilder แบบต่างๆ และตรวจสอบความจุ using System; using System.Text; public class Demo { public static void Main(String[] args)

  10. การใช้ Enumerator วนลูปผ่าน BitArray ใน C#

    ภาพรวม BitArray ใน C# รองรับการวนลูปผ่าน IEnumerable โดยใช้ foreach หรือ Enumerator โดยตรง ซึ่งช่วยให้เข้าถึงค่า bit แต่ละตัวได้อย่างง่ายดาย ตัวอย่างที่ 1: วนลูปผ่าน BitArray สองตัวและเปรียบเทียบ using System; using System.Collections; public class Demo { public static void Main() {

  11. ค้นหาโหนดแรกใน LinkedList ที่มีค่าที่ระบุใน C#

    ภาพรวม ใน C# คลาส LinkedList<T> มีเมธอด Find(T value) ที่ใช้ค้นหาโหนดแรกที่มีค่าตรงกับที่ระบุ เมธอดนี้จะคืนค่า LinkedListNode<T> หากพบค่า หรือ null หากไม่พบ ตัวอย่างที่ 1: ค้นหาข้อความใน LinkedList ของสตริง using System; using System.Collections.Generic; public class Demo { public

  12. การหาดัชนีของสมาชิกสุดท้ายในอาร์เรย์ใน C#

    ภาพรวม เมธอด Array.GetUpperBound(Int32 dimension) คืนดัชนีสูงสุดของมิติที่ระบุ (0-based) สำหรับอาร์เรย์ 1 มิติ คือดัชนีสุดท้าย ตัวอย่าง 1: อาร์เรย์มีข้อมูล ele.StartsWith(A))); Console.WriteLine(Is the array having fixed size? = + products.IsFixedSize); Console.WriteLine(Is the ar

  13. การปรากฏครั้งแรกใน List ที่ตรงตามเงื่อนไขที่ระบุใน C#

    ภาพรวม เมธอด List<T>.Find(Predicate<T>) คืนสมาชิก แรก ที่ทำให้ predicate คืน true หาไม่เจอคืน default(T) (null สำหรับ reference type, 0 สำหรับ int, ฯลฯ) ตัวอย่าง 1: หาตัวเลขหาร 10 ลงตัว using System; using System.Collections.Generic; public class Demo { private static bool demo(int

  14. วิธีรับสมาชิกที่เหลือของ Tuple ใน C#

    ภาพรวม Tuple ที่มี 8 สมาชิกขึ้นไป จะเก็บสมาชิกที่ 8 เป็นต้นไปในคุณสมบัติ Rest (ซึ่งเป็น Tuple อีกที) สามารถเข้าถึงได้ผ่าน Rest.Item1, Rest.Item2 ... หรือ Rest.Rest ซ้อนกัน ตัวอย่าง 1: Tuple 8 สมาชิก (Item8 อยู่ใน Rest) using System; public class Demo { public static void Main(String[] args) {

  15. วิธีรับสตรีมอินพุตและเอาต์พุตมาตรฐานผ่าน Console ใน C#

    ภาพรวม คลาส Console มีคุณสมบัติ In (TextReader) สำหรับ standard input และ Out (TextWriter) สำหรับ standard output ตัวอย่าง 1: Standard Input Stream using System; public class Demo { public static void Main(string[] args) { Console.WriteLine(Displaying standard input stream...);

  16. วิธีรับ TypeCode ใน C#

    ภาพรวม เมธอด GetTypeCode() (จาก IConvertible) คืน TypeCode enum แสดงประเภทของค่า ตัวอย่าง 1: สตริง using System; public class Demo { public static void Main() { string s = Demo; Console.WriteLine(String = + s); Console.WriteLine(String Type = + s.GetType()); C

  17. วิธีแทรกสมาชิกของคอลเลกชันเข้าไปใน List ที่ดัชนีที่ระบุใน C#

    ภาพรวม เมธอด List<T>.InsertRange(Int32, IEnumerable<T>) แทรกสมาชิกหลายตัวจากคอลเลกชันเข้าไปใน List ที่ดัชนีที่กำหนด ตัวอย่าง 1: แทรกสตริง using System; using System.Collections.Generic; public class Demo { public static void Main(String[] args) { string[] strArr = { John, T

  18. วิธีดำเนินการเฉพาะเจาะจงกับแต่ละสมาชิกของ List ใน C#

    ภาพรวม เมธอด List<T>.ForEach(Action<T>) ทำการกระทำ (delegate) กับทุกสมาชิกใน List ตามลำดับ ตัวอย่าง 1: คูณ 10 using System; using System.Collections.Generic; public class Demo { public static void demo(int s) { s = s * 10; Console.WriteLine(s); } public stat

  19. วิธีเล่นเสียงบีปผ่าน Console ใน C#

    ภาพรวม เมธอด Console.Beep() เล่นเสียงบีปมาตรฐาน (800 Hz, 200 ms) ผ่านลำโพงระบบ ตัวอย่าง 1: Beep พื้นฐาน using System; public class Demo { public static void Main(String[] args) { Console.WriteLine(Displaying standard output stream...); Console.WriteLine(Standard Output Stream =

  20. วิธีสร้างสำเนาลึกของออบเจ็กต์ SortedList ใน C#

    ภาพรวม SortedList (ใน System.Collections) เก็บคู่คีย์/ค่าเรียงตามคีย์ เมธอด Clone() สร้าง shallow copy ตัวอย่าง 1: Clone SortedList สตริง using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); lis

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:114/134  20-คอมพิวเตอร์/Page Goto:1 108 109 110 111 112 113 114 115 116 117 118 119 120