PhoneNumber Structure

Represents a phone number of a user.

Definition

Namespace: MobileTrack.Common.Models
Assembly: 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

Remarks

  • 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)

Constructors

PhoneNumber Constructor is only usable in the Common assembly; to instantiate new objects, use ModelFactory methods.

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.
GetHashCodeReturns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
ParseParses 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.
TryParseTries to parse a string into a value.

Operators

Equality(PhoneNumber, PhoneNumber) Equality operator for PhoneNumber.
GreaterThan(PhoneNumber, PhoneNumber) Larger than operator for PhoneNumber.
GreaterThanOrEqual(PhoneNumber, PhoneNumber) Larger than or equal to operator for PhoneNumber.
(PhoneNumber to String) For use as implicit ToString functions.
Inequality(PhoneNumber, PhoneNumber) Inequality operator for PhoneNumber.
LessThan(PhoneNumber, PhoneNumber) Smaller than operator for PhoneNumber.
LessThanOrEqual(PhoneNumber, PhoneNumber) Smaller than or equal to operator for PhoneNumber.

Fields

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.

See Also