public string GetNetworkAdapterName()
{
foreach (ManagementObject queryObj in name.Get())
{
bool physicaladapter = Convert.ToBoolean(queryObj["PhysicalAdapter"]);
if (physicaladapter == true)
{
return Convert.ToString(queryObj["Name"]);
}
}
return null;
}
How can I get for example the first, second element of the foreach ?
GetNetworkadapterName(1) is not working
thanks
the current code will always return the first physical adapter. to modify it to allow you to tell it which to return, try something like this: