# If a value is non numeric?

If Price is nonnumeric then
Price = 0.00;

double Price;

How do I check for non numeric.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Billing EngineerCommented:
check out the TryParse() function, is available on the numerical data types:
http://blog.redditech.com/professional/difference-between-intparse-and-converttoint32-in-c/

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Director of Information TechnologyCommented:
If price is defined as a double, then price *is* numeric.  No need to check anything.
Author Commented:
say it has a value of 'a'
Commented:
Here's an example of using the TryParse() method that angellll intended you to see.  If it helps you,
credit angellll.

Dim price As String = ""   'Non numeric

Dim dPrice As Double
Double.TryParse(price, dPrice)

MsgBox(dPrice.ToString())

Director of Information TechnologyCommented:
>      double Price;

If Price is defined like that, it will _never_ have a value of 'a'.   A variable defined as a double cannot hold strings.
Commented:
Unless the value is gathered as a string and is to be assigned to a double... in which case TryParse() would be good.

I think maybe the question is a little too vague.
Senior DeveloperCommented:
Abour VBRocks example: in VBN it's possible to use IsNumeric function. Really, it is possible to to import Microsoft.VisualBasic namespace in C# and use the function in C# (not really recommended).

Read good discussion and explanation of number of approaches you may use:

http://www.codeproject.com/KB/cs/csharp-isnumeric.aspx
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.