I am in need to find out how I can find out if a provided subnet mask example (255.255.192.0) is a valid subnet mask and return true if it is valid and false if not, I already am checking if the value is over 255. A wrong subnet would be (255.64.0.0)
It makes a lot of sense in binary (11111111.01000000.00000000.00000000) A subnet can not stop having 1's, and then start having them again. My current idea involves using bitshift, but am unsure how to do it.
I am not using any libaries and am not allowed for this project
The code I am using goes something like
Console.WriteLine("Enter a subnet mask");
input = Console.ReadLine(); //Enters example of 255.64.0.0 which is invalid
Thanks in advance, ask questions if needed