PhysicalAddress.Parse Method (String)


Parses the specified String and stores its contents as the address bytes of the PhysicalAddress returned by this method.

Namespace:   System.Net.NetworkInformation
Assembly:  System (in System.dll)

public static PhysicalAddress Parse(
	string address


Type: System.String

A String containing the address that will be used to initialize the PhysicalAddress instance returned by this method.

Return Value

Type: System.Net.NetworkInformation.PhysicalAddress

A PhysicalAddress instance with the specified address.

Exception Condition

The address parameter contains an illegal hardware address.

This exception also occurs if the address parameter contains a string in the incorrect format.

The address parameter must contain a string that can only consist of numbers and upper-case letters as hexadecimal digits. Some examples of string formats that are acceptable are as follows:




Note that an address that contains f0-e1-d2-c3-b4-a5 will fail to parse and throw an exception.

Use the GetAddressBytes method to retrieve the address from an existing PhysicalAddress instance.

The following code example creates a PhysicalAddress instance by calling the Parse method.

public static PhysicalAddress StrictParseAddress(string address)
    PhysicalAddress newAddress = PhysicalAddress.Parse(address);
    if (PhysicalAddress.None.Equals(newAddress))
        return null;

    return newAddress;

.NET Framework
Available since 2.0
Return to top