This blog demnostrates how to validate an ip address without doing much of code and without using regex, here i have taken help of System.Net namespace and IPAddress class. The TryParse function of IPAddress determines whether an IP Address is a validate IP Address or not. See the below demonstrator that helps validating IPAddress.
  1. static void Main()
  2. {
  3. IPAddress ip;
  4. Console.WriteLine("Enter IP Address");
  5. string ipaddress = Console.ReadLine();
  6. bool ValidateIP = IPAddress.TryParse(ipaddress, out ip);
  7. if (ValidateIP)
  8. Console.WriteLine("This is a valide ip address");
  9. else
  10. Console.WriteLine("This is not a valide ip address");
  11. }