tags:

views:

288

answers:

2

I can use System.Net.IPAddress to represent a single IP Address, but what can I use to represent an entire subnet, including the network address and the subnet mask?

EDIT: add missing "and its" between subnet and mask.

+1  A: 

Use an IPAddress (255.255.255.0 is a netmask and a valid IP Address)

10.0.0.255 is also a valid IPAddress representing the C class network (subnet) of 10.0.0.1 - 10.0.0.254

Update:

IPAddress("10.3.5.255") is a single IPAddress representing the entire "255.255.255.0" subnet.

John Weldon
apologies - my question didn't match the title. I've fixed the title.
Simon
+2  A: 

I believe you can use the System.Net.IPAddress to also represent a subnet mask. It's of the same form, and the only real operation you need to do w/ it is a bitmask based on the bytes of the subnet address.

System.Net.IPAddress i = System.Net.IPAddress.TryParse("10.10.1.1");
Byte[] b = i.GetAddressBytes();
chris.w.mclean
apologies - my question didn't match the title. I've fixed the title.
Simon