This is my code for find MAC address, but it show same result when I run this in any device?
public string GetMACAddress1()
{
try
{
NetworkInterface[] anics=NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in anics)
{
if (amacaddress == String.Empty)
{
IPInterfaceProperties properties =adapter.GetIPProperties();
amacaddress = adapter.GetPhysicalAddress().ToString();
}
}
return "MAC Address is :- " + amacaddress;
}
catch
{
return "error";
}
}
How can I got this.?
amacaddresswon't beEmptyanymore, so you won't enter theifanymore. Therefore, the rest of yourforeachloop is useless