C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...









validate IP address


Posted Date: 08 May 2008    Resource Type: Code Snippets    Category: C# Syntax

Posted By: narasimha       Member Level: Gold
Rating:     Points: 5



1.
public bool IsValidIP(string addr)
2.
{
3.
//create our match pattern
4.
string pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.
5.
([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";
6.
//create our Regular Expression object
7.
Regex check = new Regex(pattern);
8.
//boolean variable to hold the status
9.
bool valid = false;
10.
//check to make sure an ip address was provided
11.
if (addr == "")
12.
{
13.
//no address provided so return false
14.
valid = false;
15.
}
16.
else
17.
{
18.
//address provided so use the IsMatch Method
19.
//of the Regular Expression object
20.
valid = check.IsMatch(addr, 0);
21.
}
22.
//return the results
23.
return valid;
24.
}

For more details, visit http://www.eggheadcafe.com/community/aspnet/2/10034676/try-this.aspx




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Data bind a Control to an Enum
Previous Resource: captcha(UPDATED)
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



Read TATA Nano reviews.
dotNet Slackers   BizTalk Adaptors    Web Design   Scripts
Are you waiting for engineering entrance result? Watch here for engineering entrance results.
accuconference

Contact Us    Privacy Policy    Terms Of Use