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

    ภาพรวม Decimal.ToUInt16(Decimal value) แปลงค่า Decimal เป็น ushort (0 ถึง 65535) ตัดทศนิยมทิ้ง (truncate) โยน Exception หากเกินขอบเขต ตัวอย่างที่ 1: แปลง 875.647 เป็น ushort using System; public class Demo { public static void Main() { Decimal val = 875.647m; Console.WriteL

  2. การตรวจสอบว่า OrderedDictionary เป็น Read-Only ใน C#

    ภาพรวม OrderedDictionary.IsReadOnly คืนค่า bool บ่งบอกว่าคอลเลกชันอ่านอย่างเดียวหรือไม่ (ปกติเป็น false) รองรับ Contains(key) ตรวจสอบคีย์ ตัวอย่างที่ 1: ตรวจสอบ IsReadOnly และ Contains ด้วยคีย์ตัวเลข using System; using System.Collections; using System.Collections.Specialized; public class Demo {

  3. การเพิ่มโหนดใหม่ที่จุดเริ่มต้นของ LinkedList ใน C#

    ภาพรวม LinkedList<T>.AddFirst(T value) เพิ่มโหนดใหม่ที่จุดเริ่มต้น (head) ของลิสต์ ทำให้โหนดเดิมเลื่อนไปเป็นตัวที่สอง ตัวอย่างที่ 1: เพิ่มข้อมูลหลายตัวแล้วเพิ่มที่หน้าสุด using System; using System.Collections.Generic; public class Demo { public static void Main() { LinkedLis

  4. การเพิ่มข้อมูลจากคอลเลกชันไปยังท้าย List ใน C#

    ภาพรวม List<T>.AddRange(IEnumerable<T> collection) เพิ่มสมาชิกจากคอลเลกชันไปต่อท้ายลิสต์ ทั้งอาร์เรย์และลิสต์อื่น ตัวอย่างที่ 1: เพิ่มอาร์เรย์สตริง 2 ค่าไปท้าย List สตริง using System; using System.Collections.Generic; public class Demo { public static void Main(String[] args)

  5. การเพิ่มคีย์และค่าที่ระบุลงใน HybridDictionary ใน C#

    ภาพรวม HybridDictionary.Add(key, value) เพิ่มคู่คีย์/ค่าใหม่ คีย์ต้องไม่ซ้ำ รองรับการตรวจสอบ IsFixedSize และ IsReadOnly ตัวอย่างที่ 1: เพิ่ม 4 คู่และตรวจสอบคุณสมบัติ using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main()

  6. การคัดลอก ListDictionary ไปยังอาร์เรย์ที่ดัชนีที่กำหนดใน C#

    ภาพรวม ListDictionary.CopyTo(Array array, int index) คัดลอกคู่คีย์/ค่าเป็น DictionaryEntry ไปยังอาร์เรย์ เริ่มที่ดัชนีที่ระบุ เหมาะสำหรับข้อมูลขนาดเล็ก ตัวอย่างที่ 1: คัดลอก 8 คู่ไปอาร์เรย์ขนาด 8 เริ่มดัชนี 0 using System; using System.Collections; using System.Collections.Specialized; public clas

  7. การคัดลอก OrderedDictionary ไปยังอาร์เรย์ที่ดัชนีที่กำหนดใน C#

    ภาพรวม OrderedDictionary.CopyTo(Array array, int index) คัดลอกคู่คีย์/ค่าเป็น DictionaryEntry ไปยังอาร์เรย์ เริ่มที่ดัชนีที่ระบุ ลำดับจะถูกเก็บรักษา ตัวอย่างที่ 1: คัดลอก 5 คู่ไปอาร์เรย์ขนาด 5 เริ่มดัชนี 0 using System; using System.Collections; using System.Collections.Specialized; public class D

  8. การคัดลอก StringCollection ไปยังอาร์เรย์ที่ดัชนีที่กำหนดใน C#

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

  9. การคัดลอก StringDictionary ไปยังอาร์เรย์ที่ดัชนีที่กำหนดใน C#

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

  10. การคัดลอกข้อมูลจากคอลเลกชันไปยังช่วงของ ArrayList ใน C#

    ภาพรวม ArrayList.SetRange(int index, ICollection c) คัดลอกข้อมูลจากคอลเลกชันไปแทนที่ช่วงใน ArrayList เริ่มที่ดัชนีที่ระบุ ตัวอย่างที่ 1: แทนที่ 2 สมาชิกแรกด้วยอาร์เรย์สตริง using System; using System.Collections; public class Demo { public static void Main() { ArrayList arrList = n

  11. การคัดลอก LinkedList ทั้งหมดไปยังอาร์เรย์ใน C#

    ภาพรวม LinkedList<T>.CopyTo(T[] array, int index) คัดลอกข้อมูลจาก LinkedList ไปยังอาร์เรย์ ตามลำดับจากหัว (head) ไปหาง (tail) ตัวอย่างที่ 1: คัดลอก 3 สมาชิกไปอาร์เรย์ขนาด 5 เริ่มดัชนี 0 using System; using System.Collections.Generic; public class Demo { public static void Main() {

  12. การคัดลอก Stack ไปยังอาร์เรย์ใน C#

    ภาพรวม Stack<T>.CopyTo(T[] array, int index) คัดลอกข้อมูลจาก Stack ไปยังอาร์เรย์ โดยลำดับจะเป็นจากบนสุด (top) ไปด้านล่าง ตัวอย่างที่ 1: คัดลอก Stack 10 สมาชิกไปอาร์เรย์ขนาด 10 เริ่มดัชนี 0 using System; using System.Collections.Generic; public class Demo { public static void Main() {

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

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

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

    ภาพรวม Collection<T>.CopyTo(T[] array, int index) คัดลอกข้อมูลทั้งหมดไปยังอาร์เรย์ปลายทาง เริ่มที่ดัชนีที่ระบุ ตัวอย่างที่ 1: คัดลอก 8 สมาชิกไปอาร์เรย์ขนาด 10 เริ่มดัชนี 2 using System; using System.Collections.ObjectModel; public class Demo { public static void Main() { Coll

  15. การตรวจสอบว่า List มีสมาชิกที่ระบุหรือไม่ใน C#

    ภาพรวม List<T>.Contains(T item) ตรวจสอบว่ามีสมาชิกที่ระบุในลิสต์หรือไม่ คืนค่า bool ตัวอย่างที่ 1: ตรวจสอบสมาชิกใน List สตริงสองตัว using System; using System.Collections.Generic; public class Demo { public static void Main(String[] args) { List<string> list1 = new List

  16. การคัดลอกสตริงไปยังสตริงอีกตัวใน C#

    ภาพรวม String.Copy(String str) สร้างสตริงใหม่ที่มีค่าเหมือนกันทุกประการ (deep copy สำหรับสตริง) คืนค่า string ใหม่ ตัวอย่างที่ 1: คัดลอกสตริง Kevin ไปตัวใหม่ using System; public class Demo { static public void Main() { string str1 = Kevin; string str2 = String.Copy(str1);

  17. การคัดลอก ArrayList ทั้งหมดไปยังอาร์เรย์ 1 มิติใน C#

    ภาพรวม ArrayList.CopyTo(Array array) คัดลอกข้อมูลทั้งหมดไปยังอาร์เรย์ปลายทาง เริ่มที่ดัชนี 0 โดยอัตโนมัติ ตัวอย่างที่ 1: คัดลอกสตริงไปอาร์เรย์ String[] ขนาด 10 using System; using System.Collections; public class Demo { public static void Main() { ArrayList list = new ArrayList();

  18. การสร้าง Shallow Copy ของ BitArray ใน C#

    ภาพรวม BitArray.Clone() สร้าง shallow copy คืนค่า object ต้องแปลงเป็น BitArray อีกครั้ง คัดลอกค่า bit ทั้งหมดแต่เป็นอินสแตนซ์ใหม่ ตัวอย่างที่ 1: Clone BitArray ขนาด 5 ตรวจสอบค่าแต่ละ bit using System; using System.Collections; public class Demo { public static void Main() { BitArra

  19. การสร้าง SortedList ใน C#

    ภาพรวม SortedList จัดเก็บคู่คีย์/ค่า และจัดเรียงตามคีย์อัตโนมัติ รองรับการเข้าถึงด้วยคีย์หรือดัชนี ตัวอย่างที่ 1: สร้าง SortedList และวนลูปด้วย foreach และ Enumerator using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList sor

  20. การคัดลอกข้อมูล ArrayList ไปยังอาร์เรย์ใหม่ใน C#

    ภาพรวม ArrayList.ToArray() คัดลอกข้อมูลทั้งหมดสร้างอาร์เรย์ใหม่ (object[]) โดยอัตโนมัติ ไม่ต้องระบุขนาดหรือดัชนี ตัวอย่างที่ 1: คัดลอกสตริง 10 ตัวไปอาร์เรย์ใหม่ using System; using System.Collections; public class Demo { public static void Main() { ArrayList list = new ArrayList(10

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