I have a task to complete in C#. I have a Subnet Mask: 255.255.128.0.
I need to find the number of bits in the Subnet Mask, which would be, in this case, 17.
string ip = "255.255.128.0"; string a = ""; ip.Split('.').ToList().ForEach(x => a += Convert.ToInt32(x, 2).ToString()); int ones_found = a.Replace("0", "").Length;