views:

604

answers:

2

It's simple enough to code up a class to store/validate something like 192.168.0.0/16, but I was curious if a native type for this already existed in .NET? I would imagine it would work a lot like IPAddress:

CIDR subnet = CIDR.Parse("192.168.0.0/16");

Basically it just needs to make sure you're working with an IPv4 or IPv6 address and then that the number of bits your specifying is valid for that type.

+1  A: 

No there is such native type in .NET, you will need to develop one your self.

Baget
A: 

You can use the code from CodePlex to do just that:

http://ipnetwork.codeplex.com/

Koen Zomers