Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
karthikeya Boyini

A MAC address of a device is a media access control address. It is a unique identifier assigned to a network.

The MAC address technology is used by many technologies such as Ethernet, Bluetooth, Fibre Channel, etc.

Here, we will use the following method to check for all the network interfaces on the computer.

NetworkInterface.GetAllNetworkInterfaces

For this, the NetworkInterfaceType Enumeration is also used to specify the type of network interfaces.

string addr = "";
foreach (NetworkInterface n in NetworkInterface.GetAllNetworkInterfaces()) {
   if (n.OperationalStatus == OperationalStatus.Up) {
      addr += n.GetPhysicalAddress().ToString();
      break;
   }
}
return addr;

Above, we have used the GetPhysicalAddress() method to extract the MAC address.

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.