ภาพรวม SortedSet<T> (ใน System.Collections.Generic) คือคอลเลกชันที่ไม่มีค่าซ้ำ และจัดเรียงสมาชิกอัตโนมัติตามลำดับ (ใช้ comparer) คุณสมบัติหลัก ลำดับคุณสมบัติคำอธิบาย 1ComparerIComparer<T> ที่ใช้เรียงลำดับ 2Countจำนวนสมาชิก 3Maxค่าสูงสุดตาม comparer
ภาพรวม SortedSet<T> (ใน System.Collections.Generic) คือคอลเลกชันที่ไม่มีค่าซ้ำ และจัดเรียงสมาชิกอัตโนมัติตามลำดับ (ใช้ comparer) คุณสมบัติหลัก ลำดับคุณสมบัติคำอธิบาย 1ComparerIComparer<T> ที่ใช้เรียงลำดับ 2Countจำนวนสมาชิก 3Maxค่าสูงสุดตาม comparer
ภาพรวม เมธอด LinkedList<T>.FindLast(T value) คืน LinkedListNode<T> ของโหนดสุดท้ายที่มีค่าตรงกับพารามิเตอร์ (คืน null หากไม่พบ) ตัวอย่างที่ 1: LinkedList ของจำนวนเต็ม มีค่าซ้ำ using System; using System.Collections.Generic; public class Demo { public static void Main() {
ภาพรวม เมธอด 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
ภาพรวม เมธอด 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);
ภาพรวม เมธอด Type.GetNestedTypes() คืนอาร์เรย์ Type[] ของทุกชนิดข้อมูลที่ประกาศซ้อน (nested) ภายในชนิดนั้น สามารถระบุ BindingFlags ได้ ตัวอย่างที่ 1: ไม่ระบุ BindingFlags (default: public instance) using System; public class Demo { public static void Main() { Type type1 = typeof(Su
ภาพรวม StringCollection มี SyncRoot ใช้กับ lock เพื่อให้การเข้าถึงเป็น thread-safe ตัวอย่างที่ 1: เพิ่มจากอาร์เรย์ ลบ แล้วล็อก SyncRoot using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollect
ภาพรวม 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
ภาพรวม 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
ภาพรวม 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 =
ภาพรวม 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
ภาพรวม foreach ใช้วนลูปอ่านสมาชิกอาร์เรย์ตามลำดับ ไม่ต้องจัดการดัชนีเอง ยังมีเมธอดสแตติก Array.Exists สำหรับตรวจสอบเงื่อนไข ตัวอย่างที่ 1: วนลูปอาร์เรย์สตริงและใช้ Array.Exists ele.StartsWith(E))); Console.WriteLine(Is the array having fixed size? = + products.IsFixedSize); } } ผลลัพ
ภาพรวม โครงสร้าง 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; //
ภาพรวม ใช้คำสั่ง INSERT INTO ... SELECT ... เพื่อคัดลอกข้อมูลจากตารางต้นทางไปยังตารางปลายทางได้ในคำสั่งเดียว ขั้นตอน สร้าง DemoTable1 มี Id INT, FirstName VARCHAR(20) แทรกข้อมูล 2 แถว สร้าง DemoTable2 มี EmployeeId INT, EmployeeName VARCHAR(20) คัดลอกข้อมูลด้วย INSERT INTO DemoTabl
ภาพรวม ต้องการสุ่มลำดับแถวแต่ยังคงจับกลุ่มค่าที่เหมือนกันไว้ด้วยกัน ใช้ ORDER BY RAND(StudentMarks * 100 * RAND()) สร้างค่าสุ่มที่ขึ้นกับค่าคอลัมน์ ทำให้แถวที่มีค่าเท่ากันได้ค่าสุ่มใกล้เคียงกัน ขั้นตอน สร้างตาราง DemoTable มี StudentId (PK, AI) และ StudentMarks แทรกข้อมูลมีค่าซ้ำ: 98, 98,
ภาพรวม ใช้คำสั่ง 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
ภาพรวม 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
ภาพรวม 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)
ภาพรวม เมธอด 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);
ภาพรวม StringCollection (ใน System.Collections.Specialized) ให้เมธอด Add(string) เพื่อเพิ่มสตริงต่อท้ายคอลเลกชัน ตัวอย่างที่ 1: เพิ่มชื่อหลายรายการ using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection strCol = new Stri
ภาพรวม Collection<T> (ใน System.Collections.ObjectModel) ให้เมธอด Add(T item) เพื่อเพิ่มสมาชิกต่อท้าย รองรับการแจ้งเตือนเมื่อมีการเปลี่ยนแปลง (ผ่าน protected methods) เหมาะสำหรับสร้างคอลเลกชันแบบกำหนดเอง ตัวอย่างที่ 1: เพิ่มจำนวนเต็มและตรวจสอบ Contains using System; using System.Collections.O