title: How do I retrieve only Ethernet MAC Address in C#
body: <p>I want to get MAC address of Ethernet Only but It sometime shows Wifi MAC Address too.</p>
  <p>I Tried this code and while debugging I found out PC used only Wifi Network Interface Type. But whenever Ethernet is unplugged the code works. Network Interface Type changes to ethernet itself.</p>
  <pre><code>public static PhysicalAddress GetMacAddress()
  {
         foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
         {
             // Only consider Ethernet network interfaces
             if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet) 
             {
                 return nic.GetPhysicalAddress();
             }
             else
             {
                 MessageBox.Show(&quot;Error &quot;, &quot;Error!&quot;);
                 Environment.Exit(1);
             }
         }
         return null;
  }
  </code></pre>