Walter.Net.Networking
ParseNetwork(IPAddress,Int32) Method
Walter.Net.Networking Assembly > Walter.Net.Networking Namespace > NetworkExtensionMethods Class > ParseNetwork Method : ParseNetwork(IPAddress,Int32) Method
the address to take
use the CIDR calculate the subnet mast
From a single IP address to a range
Syntax
public static INetwork ParseNetwork( 
   IPAddress address,
   int cidr
)

Parameters

address
the address to take
cidr
use the CIDR calculate the subnet mast

Return Value

Network range
Remarks
sample IPV4 192.168.1.1 with a 32 bit address, please note that IPV6 is 64 bit address so start at 64 make a narrow range cidr=32: first in range 192.168.1.0 -> Last in range 192.168.1.0 count=1 cidr=31: first in range 192.168.1.0 -> Last in range 192.168.1.0 count=1 cidr=30: first in range 192.168.1.1 -> Last in range 192.168.1.2 count=2 cidr=29: first in range 192.168.1.1 -> Last in range 192.168.1.6 count=6 cidr=28: first in range 192.168.1.1 -> Last in range 192.168.1.14 count=14 cidr=27: first in range 192.168.1.1 -> Last in range 192.168.1.30 count=30 cidr=26: first in range 192.168.1.1 -> Last in range 192.168.1.62 count=62 cidr=25: first in range 192.168.1.1 -> Last in range 192.168.1.126 count=126 cidr=24: first in range 192.168.1.1 -> Last in range 192.168.1.254 count=254 ================================SWITCH=========================================== cidr=23: first in range 192.168.0.1 -> Last in range 192.168.1.254 count=510 cidr=22: first in range 192.168.0.1 -> Last in range 192.168.3.254 count=1022 cidr=21: first in range 192.168.0.1 -> Last in range 192.168.7.254 count=2046 cidr=20: first in range 192.168.0.1 -> Last in range 192.168.15.254 count=4094 cidr=19: first in range 192.168.0.1 -> Last in range 192.168.31.254 count=8190 cidr=18: first in range 192.168.0.1 -> Last in range 192.168.63.254 count=16382 cidr=17: first in range 192.168.0.1 -> Last in range 192.168.127.254 count=32766 cidr=16: first in range 192.168.0.1 -> Last in range 192.168.255.254 count=65534 cidr=15: first in range 192.168.0.1 -> Last in range 192.169.255.254 count=131070 cidr=14: first in range 192.168.0.1 -> Last in range 192.171.255.254 count=262142 cidr=13: first in range 192.168.0.1 -> Last in range 192.175.255.254 count=524286 ================================SWITCH===========================================
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

NetworkExtensionMethods Class
NetworkExtensionMethods Members
Overload List