Introduction >

UnitParser code (.NET/C#) >

NumberParser code (.NET/C#) >

NumberP

DateParser code (.NET/C#) >

FlexibleParser code

NumberParser code (.NET/C#) >
NumberP
Similarly to what happens with NumberO, NumberP also includes some extensions to the basic NumberX functionalities (which already allow to account for non-natively-supported scenarios like NumberP numberP = new NumberP("12345e6789");). All the code dealing with its specific functionalities is stored in Constructors_NumberP.cs and in the files inside the NumberP folder.

NumberP parses string inputs into numeric types, what explains its two additional public properties:
  • OriginalString. A string variable displaying the input being parsed.
  • Config. Its underlying ParseConfig defines the configuration of the given parsing process.
ParseConfig includes two public fields which are very descriptive of what NumberP can deliver.
  • Target. A (numeric) Type variable eventually (it might be left blank) defining the target format, as determined by the property below.
  • ParseType. The ParseTypes enum lists the special parsing conditions supported by NumberP, namely:
    • Parsing only to Target. Inputs outside the range of the associated native type trigger an error.
      For example, the input "123456" with byte as Target would be wrong. Bear in mind that the default NumberP behaviour is to pass the overflowing information to BaseTenExponent and, consequently, those inputs would output 123*10^3.
    • Strictly parsing thousands separators. The .NET native Parse/TryParse methods supporting thousands separators don't care about their positions (e.g., decimal.Parse("1,0,,00", CultureInfo.InvariantCulture) doesn't trigger any error), a curious reality which is addressed by this format.
      Additionally, NumberP supports blank spaces (100 000) and two further grouping approaches: Indian (10,00,000) and Chinese (100,0000).