C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Check the string value is Integer or not.


Posted Date: 21 Apr 2009    Resource Type: Code Snippets    Category: C# Syntax
Author: Dotnet GalaxyMember Level: Diamond    
Rating: 1 out of 5Points: 8 (Rs 5)



Hi All,

The below code snippet is used for checks the given string value is integer datatype or not. It accepts one parameter which is string and return the boolean value that the passed value is integer or not.

This is a very useful common function.


public bool IsInteger(string data)
{
bool result = true;

try
{
int.Parse(data);
}
catch (FormatException)
{
result = false;
}

return result;
}


Here FormatException is thrown when the format of an argument does not meet the parameter specifications of the invokde method. ie., int.Parse

Hope it helps. Happy Coding,....



Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Using FormatException  .  Convert String to Integer  .  Check the value is Integer or not.  .  

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: Check the string value is Date or not.
Previous Resource: Find number of rows in Ultra grid
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use