Features
On the 4 year anniversary of 1.0 being published π, this release contains a number of changes:
- Updated to .NET 9.0 (prior .NET versions are still supported via .NET Standard 2.1 or 2.0 builds within the package).
- Added flags and allow filters for NATO (31 of 32 members) and OECD (31 of 38 members) countries.
- Full names for countries.
- The parse method overloads have been reduced and simplified by using a default parameter for
ParseOptions
. - A number helper to determine the appropriate number to call between two phone number instances or to dial a phone number from a specific country.
var callerNumber = PhoneNumber.Parse("+441142726444");
PhoneNumber.Parse("+441146548866").NumberToDialFrom(callerNumber); // 6548866 UK local dialling within same NDC
PhoneNumber.Parse("+447106865391").NumberToDialFrom(callerNumber); // 07106865391 UK mobile from UK landline
PhoneNumber.Parse("+33140477283").NumberToDialFrom(callerNumber); // 0033140477283 French mobile from UK landline
// Alternatively a destination number from a specific country
PhoneNumber.Parse("+441146548866").NumberToDialFrom(CountryInfo.UnitedKingdom); // 01146548866 UK landline from UK
PhoneNumber.Parse("+447106865391").NumberToDialFrom(CountryInfo.UnitedKingdom); // 07106865391 UK mobile from UK
PhoneNumber.Parse("+33140477283").NumberToDialFrom(CountryInfo.UnitedKingdom); // 0033140477283 French mobile from UK
Bug fixes
None
Behaviour changes
Prior to this version, any overload of PhoneNumber.Parse
which accepted a ParseOptions
instance would throw an ArgumentNullException
, now that the method signature uses a default parameter, if not specified, ParseOptions.Default
is used.
API changes
CountryInfo
+ public string FullName { get; }
+ public string InternationalCallPrefix { get; }
+ public bool IsNatoMember { get; }
+ public bool IsOecdMember { get; }
ParseOptions
+ public static ParseOptions AllowNatoCountries(this ParseOptions parseOptions)
+ public static ParseOptions AllowOecdCountries(this ParseOptions parseOptions)
PhoneNumber
+ public static string NumberToDialFrom(this PhoneNumber destination, CountryInfo countryInfo)
+ public static string NumberToDialFrom(this PhoneNumber destination, PhoneNumber source)
- public static PhoneNumber Parse(string value)
- public static PhoneNumber Parse(string value, ParseOptions options)
+ public static PhoneNumber Parse(string value, ParseOptions? options = null)
- public static PhoneNumber Parse(string value, CountryInfo countryInfo)
- public static PhoneNumber Parse(string value, CountryInfo countryInfo, ParseOptions options)
+ public static PhoneNumber Parse(string value, CountryInfo countryInfo, ParseOptions? options = null)
- public static PhoneNumber Parse(string value, string countryCode)
- public static PhoneNumber Parse(string value, string countryCode, ParseOptions options)
+ public static PhoneNumber Parse(string value, string countryCode, ParseOptions? options = null)
- public static bool TryParse(string value, out IEnumerable<PhoneNumber> phoneNumbers)
- public static bool TryParse(string value, ParseOptions options, out IEnumerable<PhoneNumber> phoneNumbers)
+ public static bool TryParse(string value, out IEnumerable<PhoneNumber> phoneNumbers, ParseOptions? options = null)
- public static bool TryParse(string value, out PhoneNumber? phoneNumber)
- public static bool TryParse(string value, ParseOptions options, out PhoneNumber? phoneNumber)
+ public static bool TryParse(string value, out PhoneNumber? phoneNumber, ParseOptions? options = null)
- public static bool TryParse(string value, CountryInfo countryInfo, out PhoneNumber? phoneNumber)
- public static bool TryParse(string value, CountryInfo countryInfo, ParseOptions options, out PhoneNumber? phoneNumber)
+ public static bool TryParse(string value, CountryInfo countryInfo, out PhoneNumber? phoneNumber, ParseOptions? options = null)
- public static bool TryParse(string value, string countryCode, out PhoneNumber? phoneNumber)
- public static bool TryParse(string value, string countryCode, ParseOptions options, out PhoneNumber? phoneNumber)
+ public static bool TryParse(string value, string countryCode, out PhoneNumber? phoneNumber, ParseOptions? options = null)
+ public string ToString(βUβ)