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

    การกลับลำดับอาร์เรย์หนึ่งมิติใน C# ใน C# สามารถกลับลำดับองค์ประกอบในอาร์เรย์ได้ง่ายๆ โดยใช้เมธอดสแตติก Array.Reverse() จากคลาส System.Array เมธอดนี้จะปรับเปลี่ยนอาร์เรย์ต้นฉบับ (in-place) โดยไม่ต้องสร้างอาร์เรย์ใหม่ ตัวอย่างโค้ด using System; class Demo { static void Main() { // ปร

  2. วิธีลบองค์ประกอบออกจาก ArrayList ใน C#

    การลบองค์ประกอบจาก ArrayList ใน C# ใน C# คลาส ArrayList (อยู่ใน namespace System.Collections) ใช้สำหรับจัดเก็บคอลเลกชันของออบเจ็กต์ที่มีขนาดเปลี่ยนแปลงได้ การลบองค์ประกอบออกจาก ArrayList สามารถทำได้โดยใช้เมธอด Remove() ซึ่งจะลบครั้งแรกที่พบของค่าที่ระบุ ตัวอย่างโค้ด using System; using System.Colle

  3. วิธีลบ Item ออกจาก ArrayList ใน C#

    สร้าง ArrayList และเพิ่มข้อมูล: ArrayList arr = new ArrayList(); arr.Add(Jones); arr.Add(Tom); arr.Add(Henry); ลบ Tom ด้วย Remove(): arr.Remove(Tom); ตัวอย่าง using System; using System.Collections; class Demo { static void Main(){ ArrayList arr = new ArrayList(); arr.Add(Jones);

  4. วิธีหา Substring จาก String ใน C#

    กำหนดสตริง: string s = Tom Cruise; ใช้ Contains() หา Tom: if (s.Contains(Tom) == true) { Console.WriteLine(Substring found!); } ตัวอย่าง using System; public class Demo { public static void Main() { string s = Tom Cruise; if (s.Contains(Tom) == true) { Console.Wri

  5. วิธีหาและแสดงตารางสูตรคูณใน C#

    ใช้ลูป while และจัดรูปแบบ Output: while (a <= 10) { } จัดรูปแบบ: Console.WriteLine( {0} x {1} = {2} \n , n, a, n * a); ตัวอย่าง using System; public class Demo { public static void Main() { int n = 4, a = 1; while (a <= 10) { Console.WriteLine( {0} x {1} = {2} \n , n,

  6. วิธีหาความแตกต่างของวันที่ใน C#

    ใช้ DateTime สร้างวันที่ 2 ค่า แล้วเปรียบเทียบ วันที่ 1 DateTime date1 = new DateTime(2018, 09, 15); Console.WriteLine(Date 1 : {0}, date1); วันที่ 2 DateTime date2 = new DateTime(2018, 09, 28); Console.WriteLine(Date 2 : {0}, date2); ตัวอย่าง using System; namespace Program { class Demo {

  7. วิธีพิมพ์บรรทัดว่างใน C#

    ใช้ Console.WriteLine() พร้อมสตริงว่าง: Console.WriteLine( ); ตัวอย่าง using System; namespace Program { public class Demo { public static void Main(String[] args) { Console.WriteLine( ); Console.WriteLine(Displayed a blank line above!\n); Console.Read

  8. วิธีวาด Binary Triangle ใน C#

    Binary Triangle ประกอบด้วย 0 และ 1 สลับกัน ใช้ Nested For Loop for (int i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { if (a == 1) { Console.Write(0); a = 0; } else if (a == 0) { Console.Write(1); a = 1; } } Console.Write(\n); } ถ้า n = 7 จะได้: 1 01 010 1010 10101 0101

  9. วิธีวาดรูปเพชรด้วย Nested Loop ใน C#

    วาดรูปเพชรด้วย $: $ $$$ $$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$ $$$$$ $$$ $ ควบคุม: จำนวนแถว, จำนวน $, ช่องว่าง ตัวอย่าง using System; namespace Program { public class Demo { public static void Main(String[] args) { int i, j, r, d, e; r = 5; // rows d = 1; //

  10. วิธีพิมพ์ข้อความบน Console ใน C#

    ใช้ Console.WriteLine() แสดงข้อความ string str = Tom Hanks is an actor; Console.WriteLine(str); ตัวอย่าง using System; namespace Program { public class Demo { public static void Main(String[] args) { string str = Tom Hanks is an actor; Console.WriteLine(Displaying

  11. โปรแกรม C# หาตัวอักษรที่ปรากฏมากที่สุดในสตริง

    วนลูปนับจำนวนตัวอักษรด้วยอาร์เรย์: for (int i = 0; i < s.Length; i++) a[s[i]]++; กำหนดค่า: String s = livelife!; int[] a = new int[maxCHARS]; แสดงผลตัวอักษรที่ปรากฏมากกว่า 1 ครั้ง: for (int i = 0; i 1) { Console.WriteLine(Character + (char)i); Console.WriteLine(Occurrence = +

  12. ทำความเข้าใจ Logistic Regression ใน C#

    Logistic Regression เป็น Linear Model สำหรับ Binomial Regression ใช้ในวิทยาศาสตร์การแพทย์ และทำนายแนวโน้มลูกค้าจะซื้อสินค้า ใช้ Predictor Variables ช่วยวิเคราะห์ผลลัพธ์ง่ายด้วย Odds Ratios และ Statistical Hypothesis Testing Generalized Linear Model ใช้ Non-linear Link Function: z = c₁x₁ + c₂x₂ + … c

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:35/134  20-คอมพิวเตอร์/Page Goto:1 29 30 31 32 33 34 35 36 37 38 39 40 41