本文整理汇总了C#中System.Net.IPAddress.And方法的典型用法代码示例。如果您正苦于以下问题:C# IPAddress.And方法的具体用法?C# IPAddress.And怎么用?C# IPAddress.And使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.IPAddress
的用法示例。
在下文中一共展示了IPAddress.And方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InSameSubnet
/// <summary>
/// Determines whether the IP address is in the same subnet as the
/// specified IP address.
/// </summary>
/// <param name="address">The IPAddress instance this is being called
/// for.</param>
/// <param name="other">The IP address to determine whether it is in the same
/// subnet.</param>
/// <param name="netmask">The subnetmask to apply.</param>
/// <returns>true if both IP address are located in the same subnet; Otherwise
/// false.</returns>
/// <exception cref="ArgumentNullException">The other parameter or the netmask
/// parameter is null.</exception>
/// <exception cref="ArgumentException">The netmask and IP address must be
/// of the same address family.</exception>
/// <remarks>This is an extension method for the IPAddress class.</remarks>
public static bool InSameSubnet(this IPAddress address, IPAddress other,
IPAddress netmask) {
other.ThrowIfNull("other");
netmask.ThrowIfNull("netmask");
return address.And(netmask).Equals(other.And(netmask));
}