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

    ภาพรวม SortedSet<T> (ใน System.Collections.Generic) คือคอลเลกชันที่ไม่มีค่าซ้ำ และจัดเรียงสมาชิกอัตโนมัติตามลำดับ (ใช้ comparer) คุณสมบัติหลัก ลำดับคุณสมบัติคำอธิบาย 1ComparerIComparer<T> ที่ใช้เรียงลำดับ 2Countจำนวนสมาชิก 3Maxค่าสูงสุดตาม comparer

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

    ภาพรวม เมธอด LinkedList<T>.FindLast(T value) คืน LinkedListNode<T> ของโหนดสุดท้ายที่มีค่าตรงกับพารามิเตอร์ (คืน null หากไม่พบ) ตัวอย่างที่ 1: LinkedList ของจำนวนเต็ม มีค่าซ้ำ using System; using System.Collections.Generic; public class Demo { public static void Main() {

  3. การหาดัชนีของสมาชิกแรกในอาร์เรย์ใน C#

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

  4. การดึงชนิดข้อมูล巢狂เฉพาะภายใน Type ปัจจุบันใน C#

    ภาพรวม เมธอด Type.GetNestedType(string name) คืน Type ของ nested type ที่มีชื่อตรงตามที่ระบุ (คืน null หากไม่พบ) สามารถระบุ BindingFlags ได้ ตัวอย่างที่ 1: ดึง nested type ชื่อ AdvSubject using System; public class Demo { public static void Main() { Type type1 = typeof(Subject);

  5. การดึงชนิดข้อมูล巢狀ภายใน Type ปัจจุบันใน C#

    ภาพรวม เมธอด Type.GetNestedTypes() คืนอาร์เรย์ Type[] ของทุกชนิดข้อมูลที่ประกาศซ้อน (nested) ภายในชนิดนั้น สามารถระบุ BindingFlags ได้ ตัวอย่างที่ 1: ไม่ระบุ BindingFlags (default: public instance) using System; public class Demo { public static void Main() { Type type1 = typeof(Su

  6. การเข้าถึง StringCollection แบบซิงโครไนซ์ใน C#

    ภาพรวม StringCollection มี SyncRoot ใช้กับ lock เพื่อให้การเข้าถึงเป็น thread-safe ตัวอย่างที่ 1: เพิ่มจากอาร์เรย์ ลบ แล้วล็อก SyncRoot using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollect

  7. การเข้าถึง StringDictionary แบบซิงโครไนซ์ใน C#

    ภาพรวม StringDictionary มี SyncRoot ใช้กับ lock เพื่อให้การเข้าถึงเป็น thread-safe ตัวอย่างที่ 1: เพิ่มข้อมูล แล้วล็อก SyncRoot วนลูป using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { StringDictionary strDi

  8. การตรวจสอบว่าตัวอักษรมีรหัส Surrogate หรือไม่ใน C#

    ภาพรวม Char.IsSurrogate(string, int index) ตรวจสอบว่าตัวอักษรที่ตำแหน่ง index ในสตริงเป็น surrogate code unit (high/low surrogate สำหรับ UTF-16) หรือไม่ ตัวอย่างที่ 1: มี surrogate (\uD800) using System; public class Demo { public static void Main() { string str = new String(new ch

  9. การหาโคไซน์ไฮเปอร์โบลิกย้อนกลับของค่า float ใน C#

    ภาพรวม MathF.Acosh(float) คืนค่าโคไซน์ไฮเปอร์โบลิกย้อนกลับ (inverse hyperbolic cosine) ของพารามิเตอร์ โดเมนคือ x ≥ 1 น้อยกว่า 1 คืน NaN ตัวอย่างที่ 1: ค่า 0.1 และ 0.9 (น้อยกว่า 1) using System; public class Demo { public static void Main() { float val1 = 0.1f; float val2 =

  10. การหุมุมที่ไซน์เท่ากับค่า float ใน C#

    ภาพรวม MathF.Asin(float) คืนมุม (เรเดียน) ที่มีไซน์เท่ากับพารามิเตอร์ ค่าต้องอยู่ในช่วง [-1, 1] มิฉะนั้นคืน NaN ตัวอย่างที่ 1: ค่า 0.1 และ 8.9 using System; public class Demo { public static void Main() { float val1 = 0.1f; float val2 = 8.9f; Console.WriteLine(Angl

  11. การใช้ foreach ลูปกับอาร์เรย์ใน C#

    ภาพรวม foreach ใช้วนลูปอ่านสมาชิกอาร์เรย์ตามลำดับ ไม่ต้องจัดการดัชนีเอง ยังมีเมธอดสแตติก Array.Exists สำหรับตรวจสอบเงื่อนไข ตัวอย่างที่ 1: วนลูปอาร์เรย์สตริงและใช้ Array.Exists ele.StartsWith(E))); Console.WriteLine(Is the array having fixed size? = + products.IsFixedSize); } } ผลลัพ

  12. การดึง HashCode ของอินสแตนซ์ UInt32 ใน C#

    ภาพรวม โครงสร้าง UInt32 (unsigned 32-bit integer) มีเมธอด GetHashCode() คืนค่าแฮชโค้ดของค่าตัวเลขนั้น (โดยปกติคือค่าเอง) ตัวอย่างที่ 1: ค่า 100 และ UInt16.MinValue using System; public class Demo { public static void Main() { uint val1 = 100; uint val2 = UInt16.MinValue; //

  13. การนำข้อมูลจากตารางหนึ่งไปใส่อีกตารางใน MySQL

    ภาพรวม ใช้คำสั่ง INSERT INTO ... SELECT ... เพื่อคัดลอกข้อมูลจากตารางต้นทางไปยังตารางปลายทางได้ในคำสั่งเดียว ขั้นตอน สร้าง DemoTable1 มี Id INT, FirstName VARCHAR(20) แทรกข้อมูล 2 แถว สร้าง DemoTable2 มี EmployeeId INT, EmployeeName VARCHAR(20) คัดลอกข้อมูลด้วย INSERT INTO DemoTabl

  14. การใช้ ORDER BY RAND() และจับกลุ่มข้อมูลใน MySQL

    ภาพรวม ต้องการสุ่มลำดับแถวแต่ยังคงจับกลุ่มค่าที่เหมือนกันไว้ด้วยกัน ใช้ ORDER BY RAND(StudentMarks * 100 * RAND()) สร้างค่าสุ่มที่ขึ้นกับค่าคอลัมน์ ทำให้แถวที่มีค่าเท่ากันได้ค่าสุ่มใกล้เคียงกัน ขั้นตอน สร้างตาราง DemoTable มี StudentId (PK, AI) และ StudentMarks แทรกข้อมูลมีค่าซ้ำ: 98, 98,

  15. การดึงค่าสูงสุดจากคอลัมน์ MySQL

    ภาพรวม ใช้คำสั่ง SELECT ... ORDER BY ... DESC LIMIT 1 เพื่อดึงค่าสูงสุดของคอลัมน์ ขั้นตอน สร้างตาราง DemoTable มีคอลัมน์ Value INT แทรกข้อมูล: 78, 89, 98, 58 เรียกดูข้อมูลทั้งหมด Query หาค่าสูงสุด โค้ด SQL CREATE TABLE DemoTable (Value INT); INSERT INTO DemoTable VALUES (78); IN

  16. การเข้าถึง ListDictionary แบบซิงโครไนซ์ใน C#

    ภาพรวม ListDictionary มีคุณสมบัติ SyncRoot ใช้กับ lock เพื่อให้การเข้าถึงเป็น thread-safe ตัวอย่างที่ 1: ตรวจสอบคุณสมบัติและล็อก SyncRoot using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { ListDictionary dic

  17. การดึงรหัสแฮชของคีย์ที่ระบุใน Hashtable ใน C#

    ภาพรวม Hashtable มีเมธอด GetHash(object key) คืนรหัสแฮช (hash code) ที่ใช้ภายในสำหรับคีย์ที่ระบุ (protected method ต้องสร้างคลาส繼承เพื่อเรียกใช้) ตัวอย่างที่ 1: HashCode ของคีย์ D using System; using System.Collections; public class HashCode : Hashtable { public static void Main(string[] args)

  18. การดึงสมาชิกทั้งหมดของ List ที่ตรงตาม Predicate ใน C#

    ภาพรวม เมธอด List<T>.FindAll(Predicate<T>) คืน List<T> ใหม่ที่มีสมาชิกทุกตัวที่ทำให้ predicate คืน true ตัวอย่างที่ 1: หาตัวเลขหาร 3 ลงตัว using System; using System.Collections.Generic; public class Demo { private static bool demo(int i) { return ((i % 3) == 0);

  19. การเพิ่มสตริงไปยังท้าย StringCollection ใน C#

    ภาพรวม StringCollection (ใน System.Collections.Specialized) ให้เมธอด Add(string) เพื่อเพิ่มสตริงต่อท้ายคอลเลกชัน ตัวอย่างที่ 1: เพิ่มชื่อหลายรายการ using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection strCol = new Stri

  20. การเพิ่มออบเจ็กต์ไปยังท้าย Collection ใน C#

    ภาพรวม Collection<T> (ใน System.Collections.ObjectModel) ให้เมธอด Add(T item) เพื่อเพิ่มสมาชิกต่อท้าย รองรับการแจ้งเตือนเมื่อมีการเปลี่ยนแปลง (ผ่าน protected methods) เหมาะสำหรับสร้างคอลเลกชันแบบกำหนดเอง ตัวอย่างที่ 1: เพิ่มจำนวนเต็มและตรวจสอบ Contains using System; using System.Collections.O

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