NumberStyles allows to control how to parse a string for number.
NumberStyles has the following formats:
NumberStyles also defines these composite members:
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
int thousand = int.Parse("13E8", NumberStyles.HexNumber);
int minusTwo = int.Parse("(112)", NumberStyles.Integer | NumberStyles.AllowParentheses);
double aMillion = double.Parse("1,000,000", NumberStyles.Any);
Console.WriteLine(aMillion);
decimal threeMillion = decimal.Parse("3e6", NumberStyles.Any);
Console.WriteLine(threeMillion);
decimal fivePointTwo = decimal.Parse("$5.20", NumberStyles.Currency);
Console.WriteLine(fivePointTwo);
}
}
The output:
1000000
3000000
5.20
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |