Search code examples
c#.netip-addresssubnetcidr

Is there native .NET type for CIDR subnets?


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.


Solution

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