How to

enumerate network interfaces

Published: 22. January 2009 | Updated: 22. January 2009
License: Microsoft Public License (MS-PL)
Categories: Network
Tags: C# Network Windows
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Net.NetworkInformation;

Code

NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();

foreach (NetworkInterface n in interfaces)
{
    Console.WriteLine("{0} - {1}", n.Name, n.Description);
}
Send us feedback about this snippet »



Related Snippets: