I am making a program that among other things collects system information. However I am having some problems obtaining the subnet mask. I am new to programming so this is probably related to my lack of skills. My code looks like this:
public string Subnet()
{
string Maske = "";
foreach (NetworkInterface f in NetworkInterface.GetAllNetworkInterfaces())
if (f.OperationalStatus == OperationalStatus.Up)
{
IPInterfaceProperties ipInterface = f.GetIPProperties();
foreach (UnicastIPAddressInformation unicastAddress in ipInterface.UnicastAddresses)
{
Maske = unicastAddress.IPv4Mask.ToString();
}
}
return Maske;
}
I only get 255.0.0.0 as a result. I have disabled or uninstalled the other network cards but I still get this result.