PhoneNumber Structure
Represents a phone number of a user.
Namespace: MobileTrack.Common.ModelsAssembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+ce90b2cf6b782b8d7b7fd47b3c546987c652c00f
[StructLayoutAttribute(LayoutKind.Explicit, Size = 10, CharSet = CharSet.Ansi)]
public readonly struct PhoneNumber : IEquatable<PhoneNumber>,
IComparable, IComparable<PhoneNumber>, IParsable<PhoneNumber>
- Inheritance
- Object ValueType PhoneNumber
- Implements
- IComparable, IComparablePhoneNumber, IEquatablePhoneNumber, IParsablePhoneNumber
- Empty – If Number is 0, then the phone number is considered a value.
- Adherence to E.164 and ISO 3166 –
A phone number must adhere to the
for the Number format.
For the Nation property, we use the
to discern the dial code from a whole phone number, which gets converted to the dial code for the phone number.
Also note:
- IEquatableT – This interface is implemented to quickly check PhoneNumbers for equality
- IComparable – This interface is implemented to allow us to sort phone numbers, or items with phone numbers (e.g. AccountDto or DeviceDto)
| PhoneNumber |
Constructor is only usable in the Common assembly; to instantiate new objects, use ModelFactory methods.
|
| CompareTo(Object) | Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. |
| CompareTo(PhoneNumber) | Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. |
| Equals(Object) | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object)) |
| Equals(PhoneNumber) | Indicates whether the current object is equal to another object of the same type. |
| GetHashCode | Returns the hash code for this instance. (Overrides ValueTypeGetHashCode) |
| Parse | Parses a string into a value. |
| ToString |
Returns the phone number in an E.164 format for use with third-party services (like Azure Communication Services),
but this isn't very readable for humans.
(Overrides ValueTypeToString) |
| ToString(UInt16) |
Converts a phone number to a readable string. If we are in the current nation, then it will show a local number.
|
| TryParse | Tries to parse a string into a value. |
| Empty |
Empty phone number, used to represent a value.
|
| Nation |
The nation phone code as per the ISO 3166 standard.
|
| Number |
The phone number (without a starting '0' or nation code), adhering to the E.164 specifications.
|