diff --git a/src/PhoneNumbers/CountryInfo.cs b/src/PhoneNumbers/CountryInfo.cs
index e06eea63..31babb25 100644
--- a/src/PhoneNumbers/CountryInfo.cs
+++ b/src/PhoneNumbers/CountryInfo.cs
@@ -233,6 +233,13 @@ internal string ReadNationalSignificantNumber(string value)
return ReadNationalSignificantNumber(value, startIdx);
}
+ ///
+ /// Gets a value indicting whether this shares a calling code with the specified .
+ ///
+ /// True if the both countries share a calling code, otherwise false.
+ internal bool SharesCallingCodeWith(CountryInfo countryInfo) =>
+ CallingCode.Equals(countryInfo?.CallingCode, StringComparison.Ordinal);
+
/// Char.IsDigit returns true for more than 0-9 so use a more restricted version.
private static bool IsDigit(char charVal) =>
charVal is >= '0' and <= '9';
diff --git a/test/PhoneNumbers.Tests/CountryInfoTests.cs b/test/PhoneNumbers.Tests/CountryInfoTests.cs
index 6afb8864..e810688a 100644
--- a/test/PhoneNumbers.Tests/CountryInfoTests.cs
+++ b/test/PhoneNumbers.Tests/CountryInfoTests.cs
@@ -257,6 +257,20 @@ public void ReadNationalSignificantNumber_Without_TrunkPrefix(string value) =>
.CreateCountryInfo(trunkPrefix: null, nsnLengths: new[] { 8 })
.ReadNationalSignificantNumber(value));
+ [Fact]
+ public void ShareCallingCodeWith()
+ {
+ Assert.False(CountryInfo.Canada.SharesCallingCodeWith(CountryInfo.France));
+
+ Assert.True(CountryInfo.Canada.SharesCallingCodeWith(CountryInfo.UnitedStates));
+ Assert.True(CountryInfo.Guernsey.SharesCallingCodeWith(CountryInfo.IsleOfMan));
+ Assert.True(CountryInfo.Guernsey.SharesCallingCodeWith(CountryInfo.Jersey));
+ Assert.True(CountryInfo.Guernsey.SharesCallingCodeWith(CountryInfo.UnitedKingdom));
+ Assert.True(CountryInfo.UnitedKingdom.SharesCallingCodeWith(CountryInfo.Guernsey));
+ Assert.True(CountryInfo.UnitedKingdom.SharesCallingCodeWith(CountryInfo.IsleOfMan));
+ Assert.True(CountryInfo.UnitedKingdom.SharesCallingCodeWith(CountryInfo.Jersey));
+ }
+
[Fact]
public void When_Constructed()
{