devxlogo

Check Whether or Not an IP Is Valid in C#

Check Whether or Not an IP Is Valid in C#

See below for a short function that validates a given IP address:

public static Boolean ValidateIP(string inputIP){var ipParts = inputIP.Split('.');return Int32.Parse(ipParts [0]) < 256 &&Int32.Parse(ipParts [1]) < 256&Int32.Parse(ipParts [2]) < 256 &Int32.Parse(ipParts [3]) < 256;}
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist