isnumeric keyword

V

Vikas Kumar

For Each item In Request.Form
If IsNumeric(item) Then
Try
Approved(item)
Catch ex As Exception
Response.Write(ex.Message)
End Try
End If
Next

this is code in vb.net to get all items whose check boxes are checked
i want to make same in c# what will be corressponding code
i am not getting IsNumeric in C#
what will be corresponding keyword against it
 
G

Guest

There is no equivalent of IsNumeric in C# but see something very closely...
IsNumeric Function is in Microsoft.VisualBasic namespace. So you can
reference Microsoft.VisualBasic.Runtime assembly in your project and use all
Visual Basic Functions in C# ;) Cheers :)
 
N

Nicholas Paldino [.NET/C# MVP]

Actually, that's not true. IsNumeric is a managed function, and you can
access it on the Interaction class in the Microsoft.VisualBasic namespace in
Microsoft.VisualBasic.dll.
 
W

Walter Wang [MSFT]

Hi Vikas,


Thank you for posting.

Besides above solutions, here's a kb article:

How to implement Visual Basic .NET IsNumeric functionality by using Visual
C# .NET or Visual C# 2005
http://support.microsoft.com/default.aspx?scid=kb;en-us;329488


Regards,

Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

W

Walter Wang [MSFT]

Thanks David.

I agree with you on this. While the code in the kb produces correct result
regarding null value, it indeed incurs an unnecessary exception in
Double.TryParse() call.

Anyway, the easiest way is to simply use the version in
Microsoft.VisualBasic.dll.


Regards,

Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top