UInt32.TryParse() hex-number не работает

По какой-то причине всегда выводится следующая программа консоли С#:

32
Ложные
WTF = 0

Что я делаю неправильно?

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Convert.ToUInt32("0x20", 16));
            UInt32 wtf = 0;
            Console.WriteLine(UInt32.TryParse("0x20",
                              NumberStyles.HexNumber, // I've tried also AllowHexSpecifier
                              CultureInfo.InvariantCulture,  // I've also tried CurrentCulture
                              out wtf));
            Console.WriteLine("wtf={0}", wtf);
        }
    }
}

Ответы

Ответ 2

// stupid but effective way to improve the parsing
char[] _trim_hex = new char[] {'0','x'};
int temp;

if (int.TryParse(value.TrimStart(_trim_hex), NumberStyles.HexNumber, null, out temp))
{
    // temp is good
}

Ответ 3

Избавьтесь от ведущего "0x" в строке, которую вы пытаетесь проанализировать.