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.