dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » .NET » C#
Language: .NET
Expertise: Beginner
Jul 18, 2019

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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;

}
Srinath M S
 
Thanks for your registration, follow us on our social networks to keep up-to-date