Example

 using System; using System.Globalization; namespace Samples { public class NumberStylesSample { public static void Main() { string s = "$42"; Console.WriteLine("Convert from String {0} yields {1}", s, Int32.Parse(s, NumberStyles.AllowCurrencySymbol)); s = "42.0"; Console.WriteLine("Convert from String {0} yields {1}", s, Int32.Parse(s, NumberStyles.AllowDecimalPoint)); s = "3.40282347E+38"; Console.WriteLine("Convert from String {0} yields {1}", s, Single.Parse(s, NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint)); s = "2A"; Console.WriteLine("Convert from String {0} yields {1}", s, Int32.Parse(s, NumberStyles.AllowHexSpecifier)); s = "+42"; Console.WriteLine("Convert from String {0} yields {1}", s, Int32.Parse(s, NumberStyles.AllowLeadingSign)); ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.