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

    คุณสมบัติ Item ใช้ get/set ค่าที่เกี่ยวข้องกับคีย์ที่ระบุ สามารถเพิ่มสมาชิกใหม่ได้ ถ้าคีย์ไม่มีอยู่ เพิ่มได้ด้วย: myCollection[myNonexistentKey] = myValue ตัวอย่าง using System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) {

  2. Grouping Constructs ใน Regular Expression ของ C#

    มีหมวดหมู่ตัวอักษร ตัวดำเนินการ โครงสร้างต่างๆ สำหรับกำหนด Regular Expressions หนึ่งในนั้นคือ Grouping Constructs อธิบาย sub-expressions และจับ substring ของ input string ตาราง Grouping Constructs Grouping constructคำอธิบายPatternMatches ( subexpression )จับ subexpression ที่ตรงกัน ให้หมายเลขลำดับ

  3. โปรแกรม C# หาค่าสูงสุดและต่ำสุดในอาร์เรย์

    ตั้งค่าสูงสุดและต่ำสุดเป็นสมาชิกตัวแรก แล้วเปรียบเทียบสมาชิกอื่นๆ สำหรับค่าสูงสุด: max) { max = arr[i]; } สำหรับค่าต่ำสุด: if (arr[i] < min) { min = arr[i]; } ตัวอย่าง using System; public class Demo { public static void Main() { int[] arr = new int[5] {99, 95, 93, 89, 87};

  4. ความแตกต่างระหว่าง C# และ .NET

    C# คือภาษาโปรแกรมมิ่ง .NET คือเฟรมเวิร์ก .NET มี Common Language Runtime (CLR) เป็นส่วนประกอบเสมือนของ .NET framework .NET ไม่ได้มีแค่ C# แต่ผ่านมันทำงานกับ VB, F# และอื่นๆ ได้ C# เป็นส่วนหนึ่งของ .NET มีคุณสมบัติ: Boolean Conditions Automatic Garbage Collection Standard Library Assembly Versioning

  5. โปรแกรม C# ตรวจสอบว่าสตริงมีตัวอักษรซ้ำหรือไม่ (Unique Characters)

    ใช้เมธอด Substring() ตรวจสอบแต่ละ substring ว่ามีตัวอักษรซ้ำ วนลูปจนครบความยาวสตริง ถ้ามี substring ใดตรงกัน แสดงว่ามีตัวอักษรซ้ำ ตัวอย่าง using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public class Demo { public bool Che

  6. โปรแกรม C# จัดเรียงอาร์เรย์แบบลำดับมากไปน้อย (Descending)

    เริ่มต้นอาร์เรย์: int[] myArr = new int[5] {98, 76, 99, 32, 77}; เปรียบเทียบสมาชิกแรกกับถัดไป หาค่าสูงสุด แล้วค่าสอง สาม ... if (myArr[i] < myArr[j]) { temp = myArr[i]; myArr[i] = myArr[j]; myArr[j] = temp; } i, j เริ่มต้น: i=0; j=i+1; ตัวอย่าง using System; public class Demo { public static v

  7. วัตถุประสงค์ของตัวดำเนินการ 'as' ใน C#

    ตัวดำเนินการ as ทำการแปลงชนิดระหว่างชนิดที่เข้ากันได้ คล้าย cast แต่ทำได้เฉพาะ reference conversions, nullable conversions, และ boxing conversions ไม่ทำ user-defined conversions (ใช้ cast แทน) ตัวอย่าง string s = obj[i] as string; ตัวอย่างโค้ด using System; public class Demo { public static vo

  8. ขอบเขตของตัวแปรสมาชิก private ในคลาส C#

    เฉพาะฟังก์ชันในคลาสเดียวกันเท่านั้นที่เข้าถึง private members ได้ Private ซ่อนตัวแปรและฟังก์ชันจากฟังก์ชันและอ็อบเจกต์อื่น ตัวอย่าง using System; namespace RectangleApplication { class Rectangle { private double length; private double width; public void Acceptdetails

  9. คลาส Queue ใน C# คืออะไร

    ใช้คลาส Queue แสดงคอลเลกชันแบบ First-In First-Out (FIFO) การเพิ่ม = enqueue การลบ = dequeue เมธอดสำคัญของ Queue ลำดับเมธอดและคำอธิบาย 1Clear()ลบสมาชิกทั้งหมด 2Contains(object obj)ตรวจสอบว่ามีสมาชิกในคิวหรือไม่ 3Dequeue()ลบและคืนค่าสมาชิกต้นคิว 4Enqueue(object obj)เพิ่มสมาชิกท้ายคิว 5ToArray()คัดลอ

  10. วิธีเริ่มต้นอาร์เรย์หลายมิติ (Multi-dimensional Arrays) ใน C#

    รูปแบบง่ายสุดคือ 2 มิติ: รายการของอาร์เรย์ 1 มิติ เริ่มต้นได้โดยระบุค่าในวงเล็บสำหรับแต่ละแถว: int[,] a = new int[3,4] { {0, 1, 2, 3}, /* initializers for row 0 */ {4, 5, 6, 7}, /* initializers for row 1 */ {8, 9, 10, 11} /* initializers for row 2 */ }; ตัวอย่าง using System; namesp

  11. วิธีเริ่มต้นอาร์เรย์สองมิติ (Two-dimensional Arrays) ใน C#

    อาร์เรย์ 2 มิติ คือ รายการของอาร์เรย์ 1 มิติ เริ่มต้นได้โดยระบุค่าในวงเล็บสำหรับแต่ละแถว: int[,] a = new int[4,4] { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15} }; ตัวอย่าง using System; namespace ArrayApplication { class MyArray { static void Main

  12. วิธีจัดเรียงอาร์เรย์ใน C# แบบลำดับน้อยไปมาก (Ascending)

    ขั้นแรก ตั้งค่าอาร์เรย์ที่ยังไม่จัดเรียง: int[] list = { 98, 23, 97, 36, 77 }; จัดเรียงด้วยเมธอด Sort(): Array.Sort(list); ตัวอย่าง using System; namespace Demo { public class MyApplication { public static void Main(string[] args) { int[] list = { 98, 23, 97, 36, 77 };

  13. บีบอัดและแตกไฟล์ด้วย GZIP Format ใน C#

    ใช้คลาส GZipStream สำหรับบีบอัดและแตกไฟล์แบบ GZIP บีบอัด (Compress) ใช้ GZipStream ร่วม FileStream ระบุ: ไฟล์ต้นทาง และชื่อไฟล์ zip สำหรับ output ตัวอย่าง 0) { compress.Write(b, 0, read); read = inFile.Read(b, 0, b.Length); } } แตกไฟล์ (Decompress) ใช้ GZipStream เดียวกัน ระ

  14. ความแตกต่างระหว่าง Method และ Function ใน C#

    ใน C# Method และ Function คือสิ่งเดียวกัน แต่เรียกว่า Method เพราะทำงานผ่านคลาสที่กำหนด Method คือกลุ่มคำสั่งร่วมกันทำหน้าที่ ทุกโปรแกรม C# มีอย่างน้อย 1 คลาส มีเมธอดชื่อ Main ตัวอย่าง num2) result = num1; else result = num2; return result; } ... }

  15. การใช้ foreach Loop วนลูปอ่านอาร์เรย์ใน C#

    foreach loop คล้าย for loop แต่ทำงานสำหรับทุกสมาชิกในอาร์เรย์หรือกลุ่ม ไม่มีดัชนีใน foreach ตัวอย่าง Bubble Sort แล้วแสดงผลด้วย foreach: foreach (int p in arr) Console.Write(p + ); ตัวอย่าง using System; namespace BubbleSort { class MySort { static void Main(string[] args) {

  16. อาร์เรย์หลายมิติ (Dimensional Array) ใน C#

    C# รองรับอาร์เรย์หลายมิติ ประกาศอาร์เรย์ 2 มิติของ int: int[,] a; รูปแบบง่ายสุดคือ 2 มิติ: รายการของอาร์เรย์ 1 มิติ ตัวอย่างอาร์เรย์ 2 มิติ 3 แถว 4 คอลัมน์: ตัวอย่าง using System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { int[,] a = n

  17. ขอบเขตของตัวแปรสมาชิก protected internal ในคลาส C#

    protected internal อนุญาตให้ซ่อนสมาชิกจากคลาสและฟังก์ชันอื่น ยกเว้นคลาสลูกภายในแอปพลิเคชันเดียวกัน ในตัวอย่าง คลาสสืบทอดเข้าถึงตัวแปร protected internal ได้: ตัวอย่าง using System; class One { protected internal int a = 50; private int b; } class Two : One { public Two() { Console.WriteLine(t

  18. คุณสมบัติ Item ของคลาส SortedList ใน C#

    Sorted List รวมคุณสมบัติของอาร์เรย์และแฮชเทเบิล เก็บรายการที่เข้าถึงได้ด้วยคีย์หรือดัชนี คุณสมบัติ Item ใช้ get/set ค่าที่เกี่ยวข้องกับคีย์เฉพาะใน SortedList สามารถเพิ่มสมาชิกใหม่ได้ด้วย ถ้าคีย์ไม่มีอยู่ สามารถเพิ่มได้: myCollection[myNonexistentKey] = myValue ถ้าคีย์มีอยู่แล้ว จะเขียนทับด้วยคีย์และ

  19. วิธีหาค่าต่ำสุดระหว่าง 2 จำนวนใน C#

    ขั้นแรก ประกาศและเริ่มต้นตัวเลข 2 ตัว: int num1 = 35; int num2 = 55; ใช้ if-else หาค่าต่ำสุด: if (num1 < num2) { minNum = num1; } else { minNum = num2; } ตั้งค่าต่ำสุดไว้ใน minNum แล้วพิมพ์ ตัวอย่าง using System; namespace Demo { class Program { static void Main(string[] args) {

  20. ความแตกต่างระหว่าง C# และ Visual C#

    C# และ Visual C# คือสิ่งเดียวกัน ตอนใช้ Visual Studio พัฒนา C# เรียกว่า Visual C# ถือเป็นการนำ C# ไปใช้งานจริง Microsoft Visual Studio คือ IDE จาก Microsoft พัฒนาโปรแกรม เว็บแอพ บริการเว็บ เวอร์ชันปัจจุบัน Visual Studio 2017 รองรับ .NET 3.5 ถึง 4.7 C# คือภาษาโปรแกรมมิ่งหลายรูปแบบ (multi-paradigm) เว

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:71/134  20-คอมพิวเตอร์/Page Goto:1 65 66 67 68 69 70 71 72 73 74 75 76 77