Build a subnet mask from bit count value

Namespace:  SnmpSharpNet
Assembly:  SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.7.0.0 (0.7.0.0)

Syntax

C#
public static IpAddress BuildMaskFromBits(
	int bits
)
Visual Basic (Declaration)
Public Shared Function BuildMaskFromBits ( _
	bits As Integer _
) As IpAddress
Visual C++
public:
static IpAddress^ BuildMaskFromBits(
	int bits
)

Parameters

bits
Type: System..::.Int32
Number of subnet mask bits

Return Value

New IPAddress class containing the subnet mask

Examples

This example shows how to use IpAddress.BuildMaskFromBits() method:
CopyC#
Console.WriteLine("mask 1: {0}", IpAddress.BuildMaskFromBits(23));
Console.WriteLine("mask 2: {0}", IpAddress.BuildMaskFromBits(24));
Console.WriteLine("mask 3: {0}", IpAddress.BuildMaskFromBits(25));
<i>Result:</i>
mask 1: 255.255.254.0
mask 2: 255.255.255.0
mask 3: 255.255.255.128

See Also