
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Extract MAC Address Using C#
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