"c# get subnet mask" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c# get subnet mask" answered properly. Developers are finding an appropriate answer about c# get subnet mask related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c# get subnet mask. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c# get subnet mask.
c# get subnet mask
/*
Copyright (c) 2010 Jean-Paul Mikkers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.IO;
namespace CodePlex.JPMikkers.DHCP
{
public class Utils
{
public static IPAddress GetSubnetMask(IPAddress address)
{
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
{
if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork)
{
if (address.Equals(unicastIPAddressInformation.Address))
{
return unicastIPAddressInformation.IPv4Mask;
}
}
}
}
throw new ArgumentException(string.Format("Can't find subnetmask for IP address '{0}'", address));
}
}
}
Source: www.java2s.com
All those coders who are working on the C# based application and are stuck on c# get subnet mask can get a collection of related answers to their query. Programmers need to enter their query on c# get subnet mask related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# get subnet mask for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c# get subnet mask while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c# get subnet mask". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# get subnet mask resolved professionally and stay updated to the latest C# updates.