- ทดสอบการเชื่อมต่อ Informix
- ExecuteScalar (เรียก Stored Procedure)
- ExecuteReader
- ExecuteQuery
- ExecuteNonQuery
Monthly Archives: June 2019
การเข้ารหัส string ด้วย RijndaelManaged
การเข้ารหัส string
ด้วย RijndaelManaged
- cipher ที่ได้เป็น
byte[]
- cipher ที่ได้เป็น
string
- แสดงเลขฐาน 16
ดูค่า IP Address ของ client
สร้างโปรเจ็กส์แบบ Web Application แล้วดูค่า IP Address ของ client ด้วย Request.UserHostAddress
- ไฟล์ .aspx
- ไฟล์ .asmx
Iteration statements (do, while, for, foreach)
- do
- while
- for
- foreach, in
การเข้ารหัส string ด้วย TripleDES
การเข้ารหัส string
แบบ Symmetric (SymmetricAlgorithm
) ด้วย TripleDESCryptoServiceProvider
RijndaelManaged, DESCryptoServiceProvider, RC2CryptoServiceProvider, and TripleDESCryptoServiceProvider are implementations of symmetric algorithms.
Continue readingList ใน C#
- การสร้าง
List
และเข้าถึงด้วยforeach
- การ Add และ Remove สมาชิกใน
List
- การ search และ sort สมาชิกใน
List
- การใช้งาน List กับ Class
ตัวอย่างคลาส Bank
คลาส Bank แสดงตัวอย่างการตรวจสอบ Error แล้วทำการ throw
แบบต่างๆ
- docs.microsoft.com – Introduction to classes
Transaction.cs
using System; namespace ConsoleApp1 { class Transaction { public decimal Amount { get; } public DateTime Date { get; } public string Notes { get; } public Transaction(decimal amount, DateTime date, string note) { this.Amount = amount; this.Date = date; this.Notes = note; } } }Continue reading
ตัวอย่างคลาส Fibonacci
คำนวณค่า Fibonacci แบบไม่ recursive แต่ใช้ IEnumerable
เพื่อให้เรียกใช้ด้วย foreach
ได้
FibonacciGenerator.cs
using System.Collections.Generic; namespace ConsoleApp1 { class FibonacciGenerator { private Dictionary<int, int> _cache = new Dictionary<int, int>(); private int Fib(int n) => n < 2 ? n : FibValue(n - 1) + FibValue(n - 2); private int FibValue(int n) { if (!_cache.ContainsKey(n)) { _cache.Add(n, Fib(n)); } return _cache[n]; } public IEnumerable<int> Generate(int n) { for (int i = 0; i < n; i++) { yield return FibValue(i); } } } }Continue reading
สร้าง bot ด้วย Bot Framework SDK for .NET
- ดาว์นโหลดและติดตั้ง Bot Framework SDK for .NET
- สร้าง bot
- รันทดสอบด้วย emulator
- BotBuilder Samples list
Dictionary ใน C#
Dictionary
ทำงานในลักษณะของ key, value
- การใช้งาน
Dictionary
เบื้องต้น - การใช้งาน
Dictionary
กับforeach
- ทดลองดึง value ด้วย
TryGetValue
- ตรวจสอบว่ามี key แล้วหรือยังด้วย
ContainsKey
- ดึงเฉพาะ value ทั้งหมดด้วย
ValueCollection
- ดึงเฉพาะ key ทั้งหมดด้วย
KeyCollection