473,498 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IsNumeric() in c#.net?

Hello, friends,

In VB6, we have function IsNumeric(). What is the correpsonding function in
c#.net?

Thanks.
Jun 27 '07 #1
4 3720
Hi,

Yep, e.g. Double.TryParse()

Regards, Alex
http://devkids.blogspot.com
Hello, friends,

In VB6, we have function IsNumeric(). What is the correpsonding
function in c#.net?

Thanks.

Jun 27 '07 #2
Double.TryParse is what you need, but you need to wrap it to get something
similar to IsNumeric:
http://www.tangiblesoftwaresolutions...0IsNumeric.htm
--
David Anton
www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Python
Instant C#
Instant VB
Instant C++
Instant Python
C++ to C# Converter
C++ to VB Converter
"Andrew" wrote:
Hello, friends,

In VB6, we have function IsNumeric(). What is the correpsonding function in
c#.net?

Thanks.
Jun 28 '07 #3
On Jun 27, 11:00 pm, Andrew <And...@discussions.microsoft.comwrote:
Hello, friends,

In VB6, we have function IsNumeric(). What is the correpsonding function in
c#.net?

Thanks.
This is what I've found when searching through www.google.com/codesearch,
i've put it in a class for easy access throughout the application:
/// <summary>
/// Returns whether an object is numeric or not
/// </summary>
/// <param name="o">object to check</param>
/// <returns>boolean true/false</returns>
public static bool IsNumeric(object o)
{
if (o is IConvertible)
{
TypeCode tc = ((IConvertible)o).GetTypeCode();
if (TypeCode.Char <= tc && tc <= TypeCode.Decimal)
return true;
}
return false;
}

Jun 28 '07 #4
On Jun 28, 8:31 am, mnumzane <mus...@gmail.comwrote:
In VB6, we have function IsNumeric(). What is the correpsonding function in
c#.net?

This is what I've found when searching throughwww.google.com/codesearch,
i've put it in a class for easy access throughout the application:
That's not what's being asked for in this case, I believe. For
instance, it returns false for "5". It's not a case of asking whether
the type is a numeric type, so much as whether a particular object can
be converted into a number without error.

Jon

Jun 28 '07 #5

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

Similar topics

8
2290
by: eje | last post by:
IsNumeric(value) should return false if value "can not be successfully converted to a Double." Instead I get the following error message: "Input string was not in a correct format." I use the...
4
13257
by: Eugene Anthony | last post by:
I have received the following feedback for the two functions bellow: "The ISNUMERIC test is WORTHLESS for checking for an INT value, because ISNUMERIC will happily accept DOUBLE values, such as...
14
40099
by: Kenny | last post by:
Hello, I would like to know if the function IsNumeric requires a header like #include <iostream> to be functionnal thanks ken
8
2595
by: John Bowman | last post by:
Hello, Does anyone have a good/reliable approach to implementing an IsNumeric() method that accepts a string that may represent a numerical value (eg. such as some text retrieved from an XML...
3
1741
by: martin | last post by:
Hi, is there a dotnet function (other than the old isnumeric from VB) to check whether an object is numeric or not. also I notice that all the old vb functions such as split / isnumeric /...
7
2354
by: Nathan Truhan | last post by:
All, I think I may have uncovered a bug in the IsNumeric function, or at least a misunderstanding on functionality. I am writing a Schedule Of Classes Application for our campus and have a...
8
2570
by: moondaddy | last post by:
What's the .net framework equivalent of the vb function isnumeric? If there isn't one, how can I test a string variable to see if its a number or not? I don't want to use isnumeric if possible ...
12
3037
by: sck10 | last post by:
Hello, I am trying to determine if a value is NOT numeric in C#. How do you test for "Not IsNumeric"? protected void fvFunding_ItemInserting_Validate(object sender, FormViewInsertEventArgs...
12
1630
by: Paul | last post by:
Hi, I am trying to check a string to see if it's first 3 characters are numeric and if they are, to replace those 3 characters with something else. I've tried this but nothing happens... ...
17
2256
by: MLH | last post by:
I have tested the following in immed window: ?isnumeric(1) True ?isnumeric(1.) True ?isnumeric(1.2) True ?isnumeric(1.2.2)
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7197
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
6881
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
7375
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...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4584
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
3088
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
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
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 ...

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.