Articles → .NET → Get MAC Address Of The System In C#
Get MAC Address Of The System In C#
using System;
using System.Net.NetworkInformation;
namespace GetMacAddress {
  class Program {
    static void Main(string[] args) {
      NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
      String sMacAddress = string.Empty;
      foreach(NetworkInterface adapter in nics) {
        if (sMacAddress == String.Empty) // only return MAC Address from first card  
        {
          IPInterfaceProperties properties = adapter.GetIPProperties();
          sMacAddress = adapter.GetPhysicalAddress().ToString();
        }
      }
      Console.WriteLine(sMacAddress);
    }
  }
}
| Posted By  - | Karan Gupta | 
|  | 
| Posted On  - | Friday, March 10, 2017 |