Jason Salas' WebLog

On-air and online: making people laugh, making people think, pissing people off

Sponsors

ASP.NET sites that kick ass

Pals with blogs

Podcasts I listen to

I was not aware of that...IsNumeric in C#

I'm reading Deborah Kurata's "Best Kept Secrets in .NET" (review forthcoming), and she indicates that to be able to use Visual Basic .NET's IsNumeric function in C#, you can include a reference to Microsoft.VisualBasic.dll.

Granted, Deborah's book is one written from a WinForms development standpoint, so that crowd may be well aware of this.  But for me, being a web dev looking to expand into the wonderful world of desktop programming, this is news to me.  There are code snippets-a-plenty documenting how to emulate IsNumeric in C#, but this is a cool thing to keep in one's mental rolodex.

 

Comments

Raj Kaimal said:

# October 7, 2004 9:41 PM

Geoff Appleby said:

Hey man,

Yeah, so many things that appear to be 'vb only' are really just classes and methods in the microsoft.visualbasic.dll

On this same tracvk, just remember that when whidbey comes out i'm pretty sure you'll just as easily be able to reference and use the My namespace. Of course, i'm still undecided just how much of the My namespace i want to touch. :)
# October 7, 2004 10:46 PM

Daniel Auger said:

After reading this, I poked around through are utility code here at work. I found some C# emulations using the standard methodology that you see where if it isn't the datatype, an exception is caught and a false is returned. I know this form of emulating is relatively accepted in the community, but I also know that you should not, whenever possible use exceptions as logic flow. I would hope that the VB classes are not doing this internally. Does anyone know of any metrics of the VB code vs the try catch emulation?
# October 8, 2004 10:51 AM

Justin Rogers said:

Yes, if you read the link posted by the guy above, there are actual numbers for int.Parse versus VB's IsNumeric...
# October 8, 2004 2:27 PM

Joseph Lee Hunsaker said:

The IsNumeric for C# is

UInt32 result;

if (UInt32.TryParse("234", out result))

{

//result is IsNumeric (UInt32)!!

}

# March 15, 2010 1:02 PM

bebandit said:

Thanks Joseph...works great!

# April 28, 2010 1:19 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)