MacAddress Structure

A MAC (Media Access Control) address, sometimes referred to as a hardware or physical address, is a unique, 12-character alphanumeric attribute that is used to identify individual electronic devices on a network. If set, the address must follow the following hexadecimal pattern like so: 00-B0-D0-63-C2-26

Definition

Namespace: MobileTrack.Common.Models
Assembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+ce90b2cf6b782b8d7b7fd47b3c546987c652c00f
[StructLayoutAttribute(LayoutKind.Explicit, Size = 6, CharSet = CharSet.Ansi)]
public readonly struct MacAddress : IEquatable<MacAddress>, 
	IComparable, IComparable<MacAddress>, IParsable<MacAddress>, 
	IFormattable
Inheritance
Object    ValueType    MacAddress
Implements
IComparable, IComparableMacAddress, IEquatableMacAddress, IFormattable, IParsableMacAddress

Remarks

We're using this struct rather than simply storing the address in a String for two reasons; one, we need to ensure that the address is always in the correct format, and two, to reduce memory footprint and make lookups faster.

Also note:
  • IEquatableT – This interface is implemented to quickly check MacAddresses for equality
  • IComparable – This interface is implemented to allow us to sort phone numbers, or items with Mac Addresses (for now, only DeviceDto's)

Methods

AsSpan Returns the MAC address as an array of bytes. This method is comparable to reinterpret_cast in C++.
CompareTo(MacAddress)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(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.
Equals(MacAddress)Indicates whether the current object is equal to another object of the same type.
Equals(Object)Indicates whether this instance and a specified object are equal.
(Overrides ValueTypeEquals(Object))
GetHashCodeReturns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
ParseParses a string into a value.
ToStringReturns the fully qualified type name of this instance.
(Overrides ValueTypeToString)
ToString(String, IFormatProvider)Formats the value of the current instance using the specified format.
TryParseTries to parse a string into a value.

Operators

Equality(MacAddress, MacAddress) Checks for equality between two MacAddress instances.
GreaterThan(MacAddress, MacAddress) Compares two MacAddress instances for left hand being greater than the right hand.
GreaterThanOrEqual(MacAddress, MacAddress) Compares two MacAddress instances for left hand being greater than or equal to the right hand.
(MacAddress to String) Implicit operator to convert a MacAddress to a String.
Inequality(MacAddress, MacAddress) Checks for inequality between two MacAddress instances.
LessThan(MacAddress, MacAddress) Compares two MacAddress instances for left hand being less than the right hand.
LessThanOrEqual(MacAddress, MacAddress) Compares two MacAddress instances for left hand being less or equal to the right hand.

Fields

Empty Empty MAC Address value

See Also