473,513 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking if string

Ant
Hi, I'm wondering how you can check a string that supposed to represent a
numeric value.

e.g. in old VB6 there was a method IsNumeric().

Is there an equivelant in C#?

Many thanks for your answers in advance
Ant
Nov 17 '05 #1
2 1320
Ant <An*@discussions.microsoft.com> wrote:
Hi, I'm wondering how you can check a string that supposed to represent a
numeric value.

e.g. in old VB6 there was a method IsNumeric().

Is there an equivelant in C#?


Not really - you basically have to try to parse the string as a number
(eg using Double.TryParse).

If you really want to, you can add a reference to the
Microsoft.VisualBasic assembly, and use
Microsoft.VisualBasic.Information.IsNumeric().

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
try
{
int iValue = int.Parse(mystring);
}
catch(FormatException fe)
{
Console.WriteLine(mystring + " is not numeric");
}

"Ant" <An*@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
Hi, I'm wondering how you can check a string that supposed to represent a
numeric value.

e.g. in old VB6 there was a method IsNumeric().

Is there an equivelant in C#?

Many thanks for your answers in advance
Ant

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7551
by: - ions | last post by:
I have created a JComboBox with its Items as a list of "M" numbers ie. M1,M2,M3.......throgh too M110 (thes are the messier objects, a catolouge of deep sky objects) the user selects of of these...
6
14297
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? ...
6
2382
by: RoSsIaCrIiLoIA | last post by:
Do you know how to write a self-checking program in standard C? Do I can think that if I write in a file.c static g="1234567"; in the file.exe (or file) there is in some place...
4
2341
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
125
6470
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.