Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strange conversion result
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01196575
Message ID:
01196586
Vues:
11
>Hi All, try typing this into the immediate window
>
>
>// Assume s = "50"
>
>?Convert.ToInt32(s)
>0x00000032
>
>
>
>to get the actual value you need
>
>
>?Convert.ToInt32(s,16)
>0x00000050
>
>
>weird ?

Not weird at all :)
0x00000032 (represents a hexadecimal or base-16) is the same as 50 (in decimal notation or base-10)
so Convert.ToInt32("50") == 0x00000032

Now on the other hand when you use the oveload of ToInt32 you pass the base of which to use (base-10 is default), so Convert.ToInt32("50", 16) == 0x00000050

You probably have the Hexadecimal Display turned on in your watch window, turn it off and you will get your good old decimal numbers back.
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform