是否有原生的.NET类型CIDR子网? [英] Is there native .NET type for CIDR subnets?

查看:131
本文介绍了是否有原生的.NET类型CIDR子网?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是很简单的,以code了一个类来存储/验证像 192.168.0.0/16 ,但我很好奇,如果本机类型为这个已经在.NET中存在?我会想象它会工作很像 ip地址

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");

基本上它只是需要确保你正在使用的IPv4或IPv6地址,然后将该位数您指定的有效期为这种类型。

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.

推荐答案

没有出现这样的原生类型在.NET中,您将需要来发展你的自我。

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

这篇关于是否有原生的.NET类型CIDR子网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆