I am developing window application in C#. I am using the following code to obtain the MAC address
private void Form1_Load(object sender, EventArgs e)
{
lbl1.Text = "Hi";
string macAddresses = "";
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
if (nic.OperationalStatus == OperationalStatus.Up)
{
macAddresses += nic.GetPhysicalAddress().ToString();
break;
}
}
lbl1.Text = macAddresses;
}
In the above code I am not getting the MAC address of the primary lan card. In my computer I created two loopback adapters A & B. I have one physical Lan Card. Now I want to obtain the MAC address of the primary physical Lan Card instead of A & B. How to do this ? Can you please provide me any code or link through which I can resolve the above issue ?