Parsing numbers in base 2, 8, and 16


using System;
using System.Text;
using System.Globalization;
class Sample
{
    public static void Main()
    {
        int thirty = Convert.ToInt32("1E", 16);  // Parse in hexadecimal 
        Console.WriteLine(thirty);
        uint five = Convert.ToUInt32("101", 2);  // Parse in binary
        Console.WriteLine(five);
    }
}

The output:


30
5
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.