Live Chat Icon For mobile
Live Chat Icon

Is there a .Net way of deciding whether a string is numeric or not

Platform: WinForms| Category: Strings

VB.NET has a IsNumeric method that you can use to recognize a Short, Integer, Long, Decimal or Single numeric type. From C#, you can use try/catch to look for a particular numeric type.

	//long for a Single
	Single num;
	try 
	{
    		num = Single.Parse(someString);
	} 
	catch (Exception e) 
	{
    		// if this is hit, someString is not a Single
	}

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.