Is IP Address - CSharp System.Net

CSharp examples for System.Net:IP Address

Description

Is IP Address

Demo Code


using System.Runtime.Serialization.Formatters.Binary;
using System.Configuration;
using System.Net;
using System.Net.Mail;
using System.Drawing;
using System.Xml.Xsl;
using System.Xml;
using System.Data;
using System.Data.OleDb;
using System.IO;/*from w w w  .  j  av a 2 s .c o m*/
using System.Web.Security;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Text;
using System.Collections;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        private static bool IsIPAddress(string str1)
        {
            if (str1 == null || str1 == string.Empty || str1.Length < 7 || str1.Length > 15) return false;

            string regformat = @"^d{1,3}[.]d{1,3}[.]d{1,3}[.]d{1,3}$";

            Regex regex = new Regex(regformat, RegexOptions.IgnoreCase);
            return regex.IsMatch(str1);
        }
}

Related Tutorials