Class Address
Provides a wrapper around the string port address value to indicate what type of address the value is.
public class Address
- Inheritance
-
Address
- Inherited Members
Constructors
Address(string)
Creates a new Address with the provided string value.
public Address(string address)
Parameters
address
string
Exceptions
Properties
IsEmpty
Indicates that the address value is an empty string.
public bool IsEmpty { get; }
Property Value
IsHostName
Indicates whether the current Address is a host name address.
public bool IsHostName { get; }
Property Value
- bool
true if the address value is a valid host name address; otherwise, false.
Remarks
A host name must start with a letter, contain only alpha-numeric characters or special characters '.' and '-', and have a maximum length of 64 characters.
IsIPv4
Indicates whether the current Address is a IPv4 address.
public bool IsIPv4 { get; }
Property Value
- bool
true if the address value is a valid IPv4 address; otherwise, false.
IsSlot
Indicates whether the current Address is a slot number address.
public bool IsSlot { get; }
Property Value
- bool
true if the address value is a valid byte address; otherwise, false.
None
Represents no address value, or an empty string.
public static Address None { get; }
Property Value
Methods
DefaultIP()
Creates a new Address with the common default IP of 192.168.0.1.
public static Address DefaultIP()
Returns
DefaultSlot()
Creates a new Address with the default slot 0.
public static Address DefaultSlot()
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
FromIP(IPAddress)
public static Address FromIP(IPAddress ipAddress)
Parameters
Returns
Exceptions
- ArgumentNullException
ipAddress is null.
FromSlot(byte)
Creates a new Address instance from the provided byte slot number value.
public static Address FromSlot(byte slot)
Parameters
slot
bytethe byte number value that represents the port address.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Slot(byte)
Creates a new Address with the specified slot number.
public static Address Slot(byte slot)
Parameters
slot
byteThe slot number to create.
Returns
ToIPAddress()
public IPAddress ToIPAddress()
Returns
Exceptions
ToSlot()
public byte ToSlot()
Returns
Exceptions
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Operators
operator ==(Address?, Address?)
Determines if the provided objects are equal.
public static bool operator ==(Address? left, Address? right)
Parameters
Returns
- bool
true if the provided objects are equal; otherwise, false.
implicit operator byte(Address)
public static implicit operator byte(Address address)
Parameters
address
AddressThe value to convert.
Returns
implicit operator string(Address)
public static implicit operator string(Address address)
Parameters
address
AddressThe value to convert.
Returns
implicit operator Address(byte)
public static implicit operator Address(byte address)
Parameters
address
byteThe value to convert.
Returns
implicit operator Address(string)
public static implicit operator Address(string address)
Parameters
address
stringThe value to convert.
Returns
operator !=(Address?, Address?)
Determines if the provided objects are not equal.
public static bool operator !=(Address? left, Address? right)
Parameters
Returns
- bool
true if the provided objects are not equal; otherwise, false.