What determines the MAC detection order from machine to machine?

The code I have included polls my machine and returns all of the MAC addresses it finds.  On my machine it consistently finds the wireless card first followed by the Ethernet card.  Is this the case on all machines?  Is there a way to specify one over the other?  Thank you.
private List<string> getMacAddys()
{
     List<string> physical_addys = new List<string>();
 
     NetworkIUnterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
     
     foreach ( NetworkInterface obj in interfaces )
          physical_addys.Add(ni.GetPhysicalAddress().ToString());
 
     return physical_addys;
}

Open in new window

YeggmeisterAsked:
Who is Participating?
 
YeggmeisterAuthor Commented:
Thank you again.  I am going to mark this question / thread as completed as my code is now working.  I hope at some point someone else can add more to it.
0
 
käµfm³d 👽Commented:
I don't see any overloads for that method, but on the individual interfaces in each slot of the array, you can query the type:
private List<string> getMacAddys()
{
    List<string> physical_addys = new List<string>();
 
    NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
 
    foreach (NetworkInterface ni in interfaces)
    {
        if (ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
        {
            physical_addys.Add(ni.GetPhysicalAddress().ToString());
        }
    }
 
    return physical_addys;
}

Open in new window

0
 
YeggmeisterAuthor Commented:
Thank you for the quick response!  This helped me tremendously.  My question, although it is strictly out of curiosity, still stands.  What determines the polling order?
0
 
käµfm³d 👽Commented:
I would imagine the OS has some internal list and the GetAllNetworkInterfaces() function receives an iterator to the beginning of the list and steps through--the OS probably has some manner of managing how this list is ordered. Vague enough for you :)

Please don't take this as the final word on the issue as I am just hypothesizing.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.