Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: Scheduled Service.. [modified] Pin
dan!sh 7-Apr-08 18:36
professional dan!sh 7-Apr-08 18:36 
GeneralRe: Scheduled Service.. Pin
ptr2void7-Apr-08 19:38
ptr2void7-Apr-08 19:38 
GeneralRe: Scheduled Service.. Pin
Jeeva Jose7-Apr-08 20:22
Jeeva Jose7-Apr-08 20:22 
QuestionC#, How to check an object to see if it is a numeric value? Pin
dougins7-Apr-08 18:19
dougins7-Apr-08 18:19 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
dan!sh 7-Apr-08 18:30
professional dan!sh 7-Apr-08 18:30 
QuestionRe: C#, How to check an object to see if it is a numeric value? Pin
dougins7-Apr-08 18:47
dougins7-Apr-08 18:47 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
dan!sh 7-Apr-08 18:53
professional dan!sh 7-Apr-08 18:53 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
Christian Graus7-Apr-08 19:15
protectorChristian Graus7-Apr-08 19:15 
The only place that IsNumeric exists, is for a char. The TryParse methods take a string, so if you have an object, you need this:

string testVal = myObject.ToString();
double d;

if (double.TryParse(testVal, out d))
{
// I used double because 23234.545 is a number and int.TryParse won't accept it
// I assume double.TryParse can parse a whole number.
}

The other way to do it is

bool isNumeric = true;
foreach(char c in myObject.ToString())
{
if (!char.IsNumber(c))
{
isNumeric = false;
break;
}
}

But this is more code, and again, it depends on if you care about decimals, writing a method to check decimals is even more messy ( you must accept one and only one decimal, and you need to respect culture, some cultures use , as a decimal point.

Christian Graus

Please read this if you don't understand the answer I've given you

"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
Jeeva Jose7-Apr-08 20:14
Jeeva Jose7-Apr-08 20:14 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
Christian Graus7-Apr-08 20:19
protectorChristian Graus7-Apr-08 20:19 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
Mircea Puiu7-Apr-08 21:33
Mircea Puiu7-Apr-08 21:33 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
blackjack21507-Apr-08 23:51
blackjack21507-Apr-08 23:51 
GeneralRe: C#, How to check an object to see if it is a numeric value? Pin
Mircea Puiu8-Apr-08 21:19
Mircea Puiu8-Apr-08 21:19 
GeneralWell, there is a simpler way... Pin
Anthony Mushrow7-Apr-08 21:59
professionalAnthony Mushrow7-Apr-08 21:59 
QuestionHow to interrupt a method in c#? Pin
daniel abcde7-Apr-08 16:17
daniel abcde7-Apr-08 16:17 
AnswerRe: How to interrupt a method in c#? Pin
daniel abcde7-Apr-08 16:21
daniel abcde7-Apr-08 16:21 
GeneralRe: How to interrupt a method in c#? Pin
Luc Pattyn7-Apr-08 17:21
sitebuilderLuc Pattyn7-Apr-08 17:21 
GeneralRe: How to interrupt a method in c#? Pin
daniel abcde7-Apr-08 21:30
daniel abcde7-Apr-08 21:30 
GeneralRe: How to interrupt a method in c#? Pin
Mircea Puiu7-Apr-08 21:55
Mircea Puiu7-Apr-08 21:55 
GeneralRe: How to interrupt a method in c#? Pin
scott_hackett9-Apr-08 2:53
scott_hackett9-Apr-08 2:53 
GeneralRe: How to interrupt a method in c#? Pin
Mircea Puiu10-Apr-08 21:29
Mircea Puiu10-Apr-08 21:29 
GeneralRe: How to interrupt a method in c#? Pin
daniel abcde14-Apr-08 0:04
daniel abcde14-Apr-08 0:04 
GeneralRe: How to interrupt a method in c#? Pin
Mircea Puiu14-Apr-08 23:27
Mircea Puiu14-Apr-08 23:27 
QuestionValidate user permissions Pin
Thedan7-Apr-08 15:40
Thedan7-Apr-08 15:40 
GeneralRe: Validate user permissions Pin
daniel abcde7-Apr-08 17:08
daniel abcde7-Apr-08 17:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.