Get subnet mask from Win32_NetworkAdapterConfiguration : Win32_NetworkAdapterConfiguration : Network C# Examples


C# Examples » Network » Win32_NetworkAdapterConfiguration »

 

Get subnet mask from Win32_NetworkAdapterConfiguration









    
using  System;
using  System.Management;

class  MainClass
{
        public  static  void  Main()
        {
                ManagementObjectSearcher  query  =  new  ManagementObjectSearcher("SELECT  *  FROM  Win32_NetworkAdapterConfiguration  WHERE  IPEnabled  =  'TRUE'")  ;
                ManagementObjectCollection  queryCollection  =  query.Get();
                foreach(  ManagementObject  mo  in  queryCollection  )
                {
                        string[]  subnets  =  (string[])mo["IPSubnet"];
                        foreach(string  subnet  in  subnets)
                        {
                                Console.WriteLine("Subnet  Mask:  {0}",  subnet);
                        }
                }
        }
}
    
   
  
   



Output

Subnet Mask: 255.255.255.0
Subnet Mask:


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» Win32_NetworkAdapterConfiguration