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

    ภาพรวม StringCollection (ใน System.Collections.Specialized) เป็นคอลเลกชันสตริงแบบไดนามิก มีเมธอด AddRange(String[]) เพิ่มหลายค่าพร้อมกัน ตัวอย่าง 1: สร้างจากอาร์เรย์ using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection str

  2. วิธีรับรหัสแฮชของ Tuple ใน C#

    ภาพรวม เมธอด Tuple.GetHashCode() คืนค่าแฮชโค้ดของ Tuple ซึ่งคำนวณจากสมาชิกทุกตัว สอง Tuple ที่มีค่าเท่ากันจะได้แฮชโค้ดเท่ากัน ตัวอย่าง 1: Tuple 8 สมาชิก (7 + nested Tuple) using System; public class Demo { public static void Main(String[] args) { var tuple1 = Tuple.Create(150, 400, 500

  3. วิธีเล่นเสียงบีปที่ปรับแต่งเองผ่าน Console ใน C#

    ภาพรวม เมธอด Console.Beep() เล่นเสียงบีปผ่อลำโพงระบบ มี overload สองแบบ: Beep() – เสียงมาตรฐาน (800 Hz, 200 ms) Beep(Int32 frequency, Int32 duration) – ระบุความถี่ (37-32767 Hz) และระยะเวลา (ms) ตัวอย่าง 1: Beep พื้นฐานและกำหนดค่า using System; public class Demo { public static void Main(Str

  4. วิธิลบสมาชิกจากดัชนีที่ระบุของ List ใน C#

    ภาพรวม เมธอด List<T>.RemoveAt(Int32) ลบสมาชิกที่ดัชนีที่ระบุ (0-based) และเลื่อนสมาชิกหลังมาหน้า ตัวอย่าง 1: ลบดัชนี 5 (สมาชิกที่ 6) using System; using System.Collections.Generic; public class Demo { public static void Main(String[] args) { List list = new List(); list.A

  5. วิธีดึงอ้างอิงของระบบสำหรับสตริงที่ระบุใน C#

    ภาพรวม เมธอด string.Intern(String) คืนอ้างอิงของสตริงใน string intern pool หากสตริงนั้นมีอยู่แล้วในพูล จะคืนอ้างอิงเดิม มิฉะนั้นจะเพิ่มเข้าไปและคืนอ้างอิงใหม่ ตัวอย่าง 1: สตริงทั่วไป using System; public class Demo { public static void Main(string[] args) { string str1 = David;

  6. ตรวจสอบสถานะ Caps Lock และ Num Lock ผ่าน Console ใน C#

    ภาพรวม คุณสมบัติ Console.CapsLock และ Console.NumberLock คืนสถานะปุ่มกด (true = กดเปิด, false = ปิด) ตัวอย่าง 1: Caps Lock using System; public class Demo { public static void Main(string[] args) { Console.WriteLine(The CAPS LOCK is on or not? + Console.CapsLock); } } ผลลัพธ์ตัวอ

  7. ตรวจสอบว่าการป้อนข้อมูล เอาต์พุต และข้อผิดพลาดถูกเปลี่ยนเส้นทางใน Console หรือไม่ใน C#

    ภาพรวม คลาส Console มีคุณสมบัติสำหรับตรวจสอบว่าสตรีมมาตรฐานถูก redirect หรือไม่: IsInputRedirected – stdin IsOutputRedirected – stdout IsErrorRedirected – stderr ตัวอย่าง 1: ตรวจสอบ Input using System; public class Demo { public static void Main(string[] args) { Console.WriteLine(Inp

  8. ตรวจสอบว่า HybridDictionary ถูกซิงโครไนซ์หรือไม่ใน C#

    ภาพรวม คุณสมบัติ IsSynchronized ของ HybridDictionary บอกว่าอินสแตนซ์นั้นปลอดภัยต่อเธรด (thread-safe) หรือไม่ โดยค่าเริ่มต้นคือ false ตัวอย่าง 1: ตรวจสอบสอง Dictionary using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() {

  9. คืนค่าฟิลด์ที่ปรากฏจำนวนครั้งที่กำหนดด้วย MySQL DISTINCT

    ภาพรวม ใช้ DISTINCT ร่วมกับ COUNT(), GROUP BY และ HAVING เพื่อกรองเฉพาะค่าที่ปรากฏซ้ำตามเงื่อนไข ไวยากรณ์ 1 ORDER BY yourColumnName; ตัวอย่าง: สร้างตารางและข้อมูล ); Query OK, 0 rows affected (0.86 sec) เพิ่มข้อมูล INSERT INTO DemoTable1500 VALUES(Adam); INSERT INTO DemoTable1500 VALUES(John);

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

    ภาพรวม คุณสมบัติ Count ของ OrderedDictionary คืนจำนวนคู่คีย์/ค่าที่มีอยู่ ตัวอย่าง 1: เพิ่ม 6 รายการแล้ว Clear using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { OrderedDictionary dict = new OrderedDictionary();

  11. วิธีรับสมาชิกที่สี่ของ Tuple ใน C#

    ภาพรวม Tuple ใน C# (System.Tuple) มีคุณสมบัติ Item1 ถึง Item7 และ Rest สำหรับสมาชิกที่ 8 ขึ้นไป สามารถเข้าถึงสมาชิกที่ 4 ผ่าน Item4 ตัวอย่าง 1: Tuple 7 สมาชิก using System; public class Demo { public static void Main(String[] args) { var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 12

  12. การรับความสูงและความกว้างหน้าต่างสูงสุดของ Console ใน C#

    ภาพรวม คุณสมบัติ Console.LargestWindowHeight และ Console.LargestWindowWidth คืนขนาดหน้าต่างคอนโซลสูงสุดที่ระบบรองรับ (ขึ้นกับความละเอียดหน้าจอและฟอนต์) ตัวอย่าง 1: ความสูงสูงสุด using System; public class Demo { public static void Main(string[] args) { Console.WriteLine(Largest Window

  13. การรับสตรีมเอาต์พุตมาตรฐานและสตรีมข้อผิดพลาดมาตรฐานผ่าน Console ใน C#

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

  14. โครงสร้าง Char ใน C#

    ภาพรวม Char ใน C# แทนอักขระ UTF-16 (16 บิต) มีเมธอดสแตติกและอินสแตนซ์มากมายสำหรับตรวจสอบและแปลงอักขระ เมธอดสำคัญ เมธอดคำอธิบาย ConvertToUtf32(Char, Char)แปลง surrogate pair UTF-16 เป็น Unicode code point ConvertToUtf32(String, Int32)แปลงอักขระ/ surrogate pair ที่ตำแหน่งในสตริงเป็น code point Eq

  15. คลาส Convert ใน C#

    ภาพรวม คลาส Convert จัดเตรียมเมธอดสแตติกสำหรับแปลงชนิดข้อมูลพื้นฐาน (base types) ระหว่างกัน เช่น ToBoolean, ToDouble, ToDecimal ฯลฯ Convert.ToBoolean(String, IFormatProvider) แปลงสตริงเป็น bool โดยใช้ข้อมูลวัฒนธรรม (culture) public static bool ToBoolean(string val, IFormatProvider provider); ตัวอย

  16. ตรวจสอบ HybridDictionary สำหรับคีย์เฉพาะใน C#

    ภาพรวม HybridDictionary (ใน System.Collections.Specialized) สลับระหว่าง ListDictionary และ Hashtable อัตโนมัติ ขึ้นกับขนาด เมธอด Contains(Object key) ตรวจสอบคีย์ ตัวอย่าง 1: ตรวจสอบคีย์ C using System; using System.Collections; using System.Collections.Specialized; public class Demo { public s

  17. ตรวจสอบว่า Hashtable มีคีย์เฉพาะหรือไม่ใน C#

    ภาพรวม Hashtable.Contains(Object key) ตรวจสอบว่ามีคีย์ที่ระบุในแฮชเทเบิลหรือไม่ คืน bool ตัวอย่าง 1: Hashtable ขนาดใหญ่ using System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add(One, Katie); hash.A

  18. ตรวจสอบว่ามีสมาชิกใน ArrayList หรือไม่ใน C#

    ภาพรวม เมธอด ArrayList.Contains(Object) ตรวจสอบว่ามีสมาชิกเท่ากับออบเจ็กต์ที่ระบุลหรือไม่ คืน true/false ตัวอย่าง 1: ตรวจสอบสตริง using System; using System.Collections; public class Demo { public static void Main() { ArrayList list = new ArrayList(); list.Add(One); lis

  19. การแทรกรายการใหม่ใน OrderedDictionary ด้วยคีย์และค่าที่ระบุใน C#

    ภาพรวม เมธอด OrderedDictionary.Insert(Int32, Object, Object) แทรกคู่คีย์/ค่าใหม่ที่ดัชนีที่ระบุ พร้อมรักษาลำดับ ตัวอย่าง 1: แทรกที่ดัชนี 7 using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { OrderedDictionary dic

  20. การแทรกสมาชิกเข้าไปใน Collection ที่ดัชนีที่ระบุใน C#

    ภาพรวม Collection<T> (ใน System.Collections.ObjectModel) เป็นคลาสฐานสำหรับคอลเลกชันกำหนดเอง มีเมธอด Insert(Int32, T) แทรกสมาชิกที่ดัชนี ตัวอย่าง 1: แทรกที่ดัชนี 5 using System; using System.Collections.ObjectModel; public class Demo { public static void Main() { Collection col =

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