Sprint.Shared.ISOCode
1.0.0
dotnet add package Sprint.Shared.ISOCode --version 1.0.0
NuGet\Install-Package Sprint.Shared.ISOCode -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sprint.Shared.ISOCode" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sprint.Shared.ISOCode" Version="1.0.0" />
<PackageReference Include="Sprint.Shared.ISOCode" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sprint.Shared.ISOCode --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sprint.Shared.ISOCode, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sprint.Shared.ISOCode@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sprint.Shared.ISOCode&version=1.0.0
#tool nuget:?package=Sprint.Shared.ISOCode&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Shared.ISOCode
Thailand Province ISO 3166-2 mapping library สำหรับระบบนิเวศ Sprint ใช้แปลงรหัสจังหวัด ISO (เช่น TH-10) เป็นชื่อจังหวัดทั้งภาษาไทยและอังกฤษ รองรับ .NET 6, 8 และ 10
✨ Features
- ครบ 77 จังหวัด — ข้อมูลจังหวัดไทยตามมาตรฐาน ISO 3166-2:TH ทุกจังหวัด
- สองภาษา — ชื่อภาษาไทยและภาษาอังกฤษพร้อมข้อมูลภาค
- Zero-allocation lookup — ใช้
Dictionaryแบบ static ค้นหาเร็ว O(1) - Case-insensitive — รองรับ
TH-10,th-10ได้เลย - สองรูปแบบการใช้งาน — Static (ไม่ต้อง setup) และ DI (Injectable)
- Multi-framework — รองรับ .NET 6.0, 8.0 (LTS) และ 10.0
⚙️ Installation
dotnet add package Sprint.Shared.ISOCode
💡 Usage
1. Static Usage (ไม่ต้อง DI — ใช้งานได้ทันที)
using Shared.ISOCode.Thailand;
// แปลงรหัสเป็นชื่อจังหวัด
string? nameTh = ThailandProvince.GetNameTh("TH-10"); // "กรุงเทพมหานคร"
string? nameEn = ThailandProvince.GetNameEn("TH-10"); // "Bangkok"
// ดึงข้อมูลครบทุก field
var province = ThailandProvince.Get("TH-57");
Console.WriteLine(province?.NameTh); // "เชียงราย"
Console.WriteLine(province?.NameEn); // "Chiang Rai"
Console.WriteLine(province?.Region); // "ภาคเหนือ"
// Pattern matching แบบ safe
if (ThailandProvince.TryGet("TH-83", out var phuket))
{
Console.WriteLine(phuket!.NameEn); // "Phuket"
}
// ดึงทั้งหมด (เรียงตาม code)
var all = ThailandProvince.GetAll();
foreach (var p in all.OrderBy(x => x.Code))
{
Console.WriteLine($"{p.Code} | {p.NameTh} | {p.NameEn}");
}
2. DI Usage (ASP.NET Core / Hosted Services)
Program.cs
using Shared.ISOCode.Extensions;
builder.Services.AddThailandISOCode();
ใช้งานผ่าน Injection
using Shared.ISOCode.Resolvers;
public class OrderService(IProvinceResolver provinceResolver)
{
public string GetShippingLabel(string isoCode)
{
var province = provinceResolver.Get(isoCode);
return province is null
? "ไม่พบจังหวัด"
: $"จัดส่งไปยัง: {province.NameTh} ({province.NameEn})";
}
}
📋 Province Code Reference
ภาคกลาง (Central) — 25 จังหวัด
| Code | ชื่อไทย | English Name |
|---|---|---|
| TH-10 | กรุงเทพมหานคร | Bangkok |
| TH-11 | สมุทรปราการ | Samut Prakan |
| TH-12 | นนทบุรี | Nonthaburi |
| TH-13 | ปทุมธานี | Pathum Thani |
| TH-14 | พระนครศรีอยุธยา | Phra Nakhon Si Ayutthaya |
| TH-15 | อ่างทอง | Ang Thong |
| TH-16 | ลพบุรี | Lop Buri |
| TH-17 | สิงห์บุรี | Sing Buri |
| TH-18 | ชัยนาท | Chai Nat |
| TH-19 | สระบุรี | Saraburi |
| TH-24 | ฉะเชิงเทรา | Chachoengsao |
| TH-25 | ปราจีนบุรี | Prachin Buri |
| TH-26 | นครนายก | Nakhon Nayok |
| TH-27 | สระแก้ว | Sa Kaeo |
| TH-60 | นครสวรรค์ | Nakhon Sawan |
| TH-61 | อุทัยธานี | Uthai Thani |
| TH-62 | กำแพงเพชร | Kamphaeng Phet |
| TH-70 | ราชบุรี | Ratchaburi |
| TH-71 | กาญจนบุรี | Kanchanaburi |
| TH-72 | สุพรรณบุรี | Suphan Buri |
| TH-73 | นครปฐม | Nakhon Pathom |
| TH-74 | สมุทรสาคร | Samut Sakhon |
| TH-75 | สมุทรสงคราม | Samut Songkhram |
| TH-76 | เพชรบุรี | Phetchaburi |
| TH-77 | ประจวบคีรีขันธ์ | Prachuap Khiri Khan |
ภาคตะวันออก (Eastern) — 4 จังหวัด
| Code | ชื่อไทย | English Name |
|---|---|---|
| TH-20 | ชลบุรี | Chon Buri |
| TH-21 | ระยอง | Rayong |
| TH-22 | จันทบุรี | Chanthaburi |
| TH-23 | ตราด | Trat |
ภาคเหนือ (Northern) — 14 จังหวัด
| Code | ชื่อไทย | English Name |
|---|---|---|
| TH-50 | เชียงใหม่ | Chiang Mai |
| TH-51 | ลำพูน | Lamphun |
| TH-52 | ลำปาง | Lampang |
| TH-53 | อุตรดิตถ์ | Uttaradit |
| TH-54 | แพร่ | Phrae |
| TH-55 | น่าน | Nan |
| TH-56 | พะเยา | Phayao |
| TH-57 | เชียงราย | Chiang Rai |
| TH-58 | แม่ฮ่องสอน | Mae Hong Son |
| TH-63 | ตาก | Tak |
| TH-64 | สุโขทัย | Sukhothai |
| TH-65 | พิษณุโลก | Phitsanulok |
| TH-66 | พิจิตร | Phichit |
| TH-67 | เพชรบูรณ์ | Phetchabun |
ภาคตะวันออกเฉียงเหนือ (Northeastern) — 20 จังหวัด
| Code | ชื่อไทย | English Name |
|---|---|---|
| TH-30 | นครราชสีมา | Nakhon Ratchasima |
| TH-31 | บุรีรัมย์ | Buri Ram |
| TH-32 | สุรินทร์ | Surin |
| TH-33 | ศรีสะเกษ | Si Sa Ket |
| TH-34 | อุบลราชธานี | Ubon Ratchathani |
| TH-35 | ยโสธร | Yasothon |
| TH-36 | ชัยภูมิ | Chaiyaphum |
| TH-37 | อำนาจเจริญ | Amnat Charoen |
| TH-38 | บึงกาฬ | Bueng Kan |
| TH-39 | หนองบัวลำภู | Nong Bua Lam Phu |
| TH-40 | ขอนแก่น | Khon Kaen |
| TH-41 | อุดรธานี | Udon Thani |
| TH-42 | เลย | Loei |
| TH-43 | หนองคาย | Nong Khai |
| TH-44 | มหาสารคาม | Maha Sarakham |
| TH-45 | ร้อยเอ็ด | Roi Et |
| TH-46 | กาฬสินธุ์ | Kalasin |
| TH-47 | สกลนคร | Sakon Nakhon |
| TH-48 | นครพนม | Nakhon Phanom |
| TH-49 | มุกดาหาร | Mukdahan |
ภาคใต้ (Southern) — 14 จังหวัด
| Code | ชื่อไทย | English Name |
|---|---|---|
| TH-80 | นครศรีธรรมราช | Nakhon Si Thammarat |
| TH-81 | กระบี่ | Krabi |
| TH-82 | พังงา | Phang Nga |
| TH-83 | ภูเก็ต | Phuket |
| TH-84 | สุราษฎร์ธานี | Surat Thani |
| TH-85 | ระนอง | Ranong |
| TH-86 | ชุมพร | Chumphon |
| TH-90 | สงขลา | Songkhla |
| TH-91 | สตูล | Satun |
| TH-92 | ตรัง | Trang |
| TH-93 | พัทลุง | Phatthalung |
| TH-94 | ปัตตานี | Pattani |
| TH-95 | ยะลา | Yala |
| TH-96 | นราธิวาส | Narathiwat |
🗂️ Province Model
public sealed record Province(
string Code, // "TH-10"
string NameTh, // "กรุงเทพมหานคร"
string NameEn, // "Bangkok"
string Region // "ภาคกลาง"
);
🛡️ IProvinceResolver Interface
public interface IProvinceResolver
{
Province? Get(string isoCode);
string? GetNameTh(string isoCode);
string? GetNameEn(string isoCode);
bool TryGet(string isoCode, out Province? province);
IReadOnlyCollection<Province> GetAll();
}
© 2026 Sprint-OMS Development Team
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
-
net6.0
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 103 | 5/6/2026 |