I have a method to validate a parameter IP Address. Being new to development as a whole I would like to know if there is a better way of doing this.
Without using IPAddress class and validating against byte, which is far better than the Int<256 approach.
public Boolean CheckIPValid(String strIP)
{
// Split string by ".", check that array length is 4
string[] arrOctets = strIP.Split('.');
if (arrOctets.Length != 4)
return false;
//Check each substring checking that parses to byte
byte obyte = 0;
foreach (string strOctet in arrOctets)
if (!byte.TryParse(strOctet, out obyte))
return false;
return true;
}