I added a little tweak in there with all due respect to OriginalGriff. This will ensure that:
1. The Adapter that is currently connected is Picked;
2. All Virtual and Pseudo Adapters will not be considered even though the are "Connected".
3. Ensure that No Null or Empty MAC is Appended.
string mac = "";
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
if (nic.OperationalStatus == OperationalStatus.Up && (!nic.Description.Contains("Virtual") && !nic.Description.Contains("Pseudo")))
if (nic.GetPhysicalAddress().ToString() != "")
mac = nic.GetPhysicalAddress().ToString();