How do I convert string to numerical value types?
Category: System, viewed: 361 time(s).
This examples show you how to convert string to its equivalent numerical values. To convert string into number type we can use the Parse method of the desired type such as the Int32.Parse(), Double.Parse().
The static method Parse() is derived from the ValueType data type allow easy conversion from a string value to the specific value type. Type that support the Parse() method including Boolean, Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32, UInt64.
Beside passing the string value to the Parse() method we can also pass a NumberStyles flag. This allows the Parse() method to handle specific properties of a number such as decimal point, currency symbol and leading or trailing signs.
Download Hundreds of Complimentary Industry Resources
Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more;
all available at no cost to you. With more than 600 complimentary offers, you'll find
plenty of titles to suit your professional interests and needs.
Click Here and Sign up today!