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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

No, the code gets all items that are numeric. If you use that to get
values from checkboxes, the code is very sensetive to changes.

The IsNumeric method is something that is left over from VB 6. There is
no corresponding method in C#. You can reference
Microsoft.VisualBasic.dll and use the IsNumeric method, but you should
really use an alternative method to identify the checkboxes.

Can't the checkboxes be identified using their name, or part of the name?

To verify that a string contains only digits, you can use a regular
expression:

If Regex.IsMatch(item, "^\d+$") Then
 
S

Steve C. Orr [MVP, MCSD]

There is no exact equivalent to the IsNumeric keyword. It's a feature of
VB.NET, and C# simply doesn't have it.
I suggest you use "TryParse" instead of IsNumeric; it is somewhat similar.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top