WorldRef 1.1.2
dotnet add package WorldRef --version 1.1.2
NuGet\Install-Package WorldRef -Version 1.1.2
<PackageReference Include="WorldRef" Version="1.1.2" />
<PackageVersion Include="WorldRef" Version="1.1.2" />
<PackageReference Include="WorldRef" />
paket add WorldRef --version 1.1.2
#r "nuget: WorldRef, 1.1.2"
#:package WorldRef@1.1.2
#addin nuget:?package=WorldRef&version=1.1.2
#tool nuget:?package=WorldRef&version=1.1.2
worldref for C# (.NET)
Offline reference data for 242 countries and territories in Arabic and English: names, flags, dial plans, currencies, geography, subdivisions. Search, sorting and phone parsing behave identically to the JavaScript package.
The library targets net8.0 and has no dependencies beyond the base library. The data is embedded in the assembly.
Install
dotnet add package WorldRef
Usage
using WorldRef;
var sa = Dataset.Find("sa")!; // case-insensitive
Console.WriteLine($"{sa.Flag} {sa.NameAr} / {sa.NameEn}");
var hits = Lookup.Search(Dataset.Countries, "السعودية", Lang.Ar); // best match first
var sorted = Lookup.SortCountries(Dataset.Countries, Lang.Ar, first: "SA");
var phone = Lookup.ParsePhone("0501234567", sa, Dataset.Countries);
Console.WriteLine($"{phone?.E164} valid={phone?.Valid} mobile={phone?.Mobile}");
Console.WriteLine(Lookup.IsValidMobile("+966501234567", sa, Dataset.Countries));
Console.WriteLine(Text.Normalize("المملكة العربية السعودية")); // folded form used for matching
Console.WriteLine(Dataset.SubdivisionsOf("SA").Count);
Models are records (Country, PhonePlan, Currency, Subdivision, ...) with PascalCase properties mapped from the snake_case JSON fields, for example NameAr, Geo.AreaKm2, Phone[0].MobilePattern.
Tests
cd csharp && dotnet test
The suite loads tests/vectors.json from the repository root, so run it from a full checkout.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.