Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#
C#
  1. C# Equivalent ของ SQL Server Data Types

    ตารางเปรียบเทียบ C# Data Types เทียบเท่า SQL Server Data Types SQL Server Data TypeC# Equivalent varbinaryByte[] binaryByte[] imageNone varcharNone charNone nvarcharString, Char[] ncharString, Char[] textNone ntextNone rowversionByte[] bitBoolean tinyintByte smallintInt16 intInt32 bigintInt64 sm

  2. #define Pre-processor Directive ใน C#

    #define กำหนด Symbol (ลำดับตัวอักษร) สร้าง Symbolic Constants #define ทำให้ Symbol นั้น Evaluate เป็น True เมื่อใช้กับ #if ตัวอย่าง #define ONE #undef TWO using System; namespace Demo { class Program { static void Main(string[] args) { #if (ONE && TWO)

  3. Base Class ใน C# คืออะไร

    Base Class คือคลาสที่มีอยู่แล้ว ให้ Derived Class (คลาสลูก) สืบทอด Members (Data/Methods) ไปใช้ แทนที่จะเขียนใหม่ทั้งหมด คลาสหนึ่งสามารถสืบทอดจากหลาย Base Classes หรือ Interfaces ได้ Syntax <access-specifier> class <base_class> { ... } class <derived_class> : <base_class> { .

  4. IDE ที่ดีที่สุดสำหรับ C# บน Windows

    IDE ที่ดีที่สุดสำหรับ C# บน Windows คือ Microsoft Visual Studio ใช้พัฒนา Website, Web Apps, Mobile Apps เป็นต้น คุณสมบัติหลัก Code Editor - Syntax Highlighting, IntelliSense Code Completion Breakpoints - ตั้ง Breakpoint ติดตามค่าตัวแปรระหว่าง Debug Extend Capability - ขยายฟังก์ชันด้วย Extensions (M

  5. Dictionary ใน C# คืออะไร

    Dictionary เป็น Collection ของ Key-Value Pairs อยู่ใน Namespace System.Collections.Generic การประกาศและ Initialize IDictionary<int, int> d = new Dictionary<int, int>(); Key เป็น int, Value เป็น int เก็บใน Object d ตัวอย่าง using System; using System.Collections.Generic; public class Dem

  6. Generic List<T> ใน C# คืออะไร

    List<T> เป็น Generic Collection ใน C# ขนาดเพิ่มได้ไดนามิก (Dynamic) ไม่เหมือน Array ที่ขนาดคงที่ การใช้งาน ประกาศ List: List<string> myList = new List<string>(); เพิ่มข้อมูล: myList.Add(mammals); หรือ Initializer: List<string> myList = new List<string>() { mammals, rep

  7. IDE สำหรับ C# นอกจาก Visual Studio

    ตัวเลือก IDE สำหรับ C# นอกจาก Visual Studio: 1. SharpDevelop Open Source IDE รันบน Windows เท่านั้น พัฒนาเป็น Alternative ของ VS เขียนด้วย C# รองรับ Git, SVN, NuGet 2. LINQPad Utility รัน C# โดยไม่ต้องมี IDE บางฟีเจอร์เสียเงิน (Autocomplete) 3. MonoDevelop Open Source รัน C# หลาย Platform: Windows,

  8. วิธีที่ดีที่สุดในการ Iterate Dictionary ใน C#

    Dictionary<TKey, TValue> เป็น Collection ของ Key-Value อยู่ใน System.Collections.Generic วิธี Iterate ที่แนะนำ สร้าง Dictionary: var d = new Dictionary<string, int>(5); เพิ่ม Key-Value: d.Add(car, 25); d.Add(bus, 28); d.Add(motorbike, 17); เรียงลำดับด้วย LINQ OrderBy: var val = from e

  9. IDE ที่ดีที่สุดสำหรับ C# บน Linux

    บน Windows ใช้ Visual Studio บน Linux IDE ที่ดีที่สุดคือ MonoDevelop (รู้จักในชื่อ Xamarin Studio) เป็น Open Source รัน C# ได้หลาย Platform: Windows, Linux, macOS มี C# Compiler ในตัว คุณสมบัติ MonoDevelop Multi-platform IDE - รองรับ Linux, Windows, macOS หลายภาษา - C#, F#, Visual Basic .NET, ฯลฯ I

  10. Thread Pools ใน C#

    Thread Pool ใน C# คือกลุ่มของ Threads ใช้ทำงานใน Background (Background Tasks) เมื่อ Thread ทำงานเสร็จ จะถูกส่งกลับ Queue เพื่อนำกลับมาใช้ใหม่ (Reuse) วิธีสร้าง Thread Pool ใช้ Namespace: using System.Threading; เรียก ThreadPool Class ผ่าน Object ใช้เมธอด QueueUserWorkItem: ThreadPool.QueueUserWork

  11. Increment (++) และ Decrement (--) Operators ใน C#

    Increment Operators มี 2 แบบ: Pre-increment (++a) และ Post-increment (a++) ตัวอย่าง Increment using System; class Demo { static void Main() { int a = 250; Console.WriteLine(a); // 250 a++; Console.WriteLine(a); // 251 ++a; Console.WriteLine(a); // 252

  12. Multicasting Delegates ใน C#

    Delegate ที่เก็บ Reference ของมากกว่าหนึ่งเมธอด เรียกว่า Multicasting Delegate ตัวอย่าง using System; delegate void myDelegate(int val1, int val2); public class Demo { public static void CalAdd(int val1, int val2) { Console.WriteLine({0} + {1} = {2}, val1, val2, val1 + val2); }

  13. Extender Provider Components ใน C#

    Extender Provider ใช้ให้ Properties กับ Components อื่นๆ ตัวอย่าง: ToolTip Component เพิ่ม Component ลง Form จะตั้งค่า ToolTip Property ให้ทุก Control Property นี้ไม่ได้อยู่ใน PropertyGrid โดยตรง myTooltip1.SetToolTip(btn1, This is ToolTip!); การ Implement Extender Provider กำหนด Component: public

  14. Punctuators ใน C# คืออะไร

    Punctuators เป็นสัญลักษณ์พิเศษใน C# ใช้จัดกลุ่มหรือแบ่งโค้ด ประกอบด้วย: ] () {}, ; * = # ตัวอย่างการใช้งาน = ใช้ในการกำหนดค่าตัวแปรหรือในคลาส Statement จบด้วย Semicolon: int a = 10; Class ใช้ Braces: class Demo { } Dictionary: var d = new Dictionary<string, int>(5); List Initialization: List&

  15. Sealed Modifiers ใน C#

    เมื่อใช้ sealed modifier กับเมธอด เมธอดนั้นจะสูญเสียความสามารถในการ Override เมธอด Sealed ต้องอยู่ใน Derived Class และต้องเป็น Overridden Method ตัวอย่าง class ClassOne { public virtual void display() { Console.WriteLine(baseclass); } } class ClassTwo : ClassOne { public sealed override voi

  16. Static / Fixed Length Arrays ใน C#

    Static Array คือโครงสร้างข้อมูลขนาดคงที่ (Fixed Size) ตัวอย่าง Static String Array: static string[] _fruits = new string[] { apple, mango }; ตัวอย่างสมบูรณ์: สร้างและเข้าถึง Static Array using System; class Demo { static void Main() { foreach (string fruits in Program.Fruits)

  17. Explicit Type Conversions ใน C# (การแปลงชนิดข้อมูลชัดเจน)

    Explicit Conversions ต้องใช้ Cast Operator การแปลงชนิดข้อมูลแบบชัดเจนโดยผู้ใช้ผ่านฟังก์ชันที่กำหนดไว้ ตัวอย่าง: Cast Double เป็น Int using System; namespace Demo { class Program { static void Main(string[] args) { double d = 345.78; int i;

  18. String และ string ใน C# แตกต่างกันอย่างไร

    String ย่อมาจาก System.String ส่วน string เป็น Alias (ชื่อเรียกอื่น) ของ System.String ใน C# ตัวอย่าง: string str = Welcome!; โดยทั่วไปใช้ String เมื่อทำงานกับคลาส: string str = String.Format(Welcome! {0}!, user); Alias ของ Data Types อื่นๆ: object: System.Object string: System.String bool: Sys

  19. ตัวอย่าง Array ใน C# ที่ดี (Best Practices)

    Array ใช้เก็บข้อมูลชุดหนึ่ง ในหน่วยความจำที่ติดกัน ตัวอย่างการใช้งาน Array ที่น่าสนใจ: 1. หาองค์ประกอบร่วมใน 3 Sorted Arrays using System; class Demo { static void commonElements(int[] one, int[] two, int[] three) { int i = 0, j = 0, k = 0; while (i < one.Length && j < two.Le

  20. Multiple Inheritance ใน C# (การสืบทอดหลายคลาส)

    C# ไม่รองรับ Multiple Inheritance โดยตรง แต่สามารถทำได้ผ่าน Interface การ Implement ด้วย Interface สร้าง 2 Interfaces: public interface BaseOne { void display(); } public interface BaseTwo { void display(); } คลาสลูก Implement ทั้งสอง Interface: public class ChildOne : BaseOne, BaseTwo { public

Total 2668 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:22/134  20-คอมพิวเตอร์/Page Goto:1 16 17 18 19 20 21 22 23 24 25 26 27 28