Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

AllowHexSpecifier doesn't parse "x1"

Posted on 2008-06-25
3
Medium Priority
?
1,090 Views
Last Modified: 2008-07-03
I'd like to parse
      int a = Int32.Parse("x1",System.Globalization.NumberStyles.AllowHexSpecifier);
but it throws FormatException "Input string was not in a correct format."

What should I be doing?
0
Comment
Question by:josgood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

by:rachitkohli
ID: 21871958
If you want to specify hex specified, its &H
example CLng("&H12")

Else in case of your function it should be just 1 & not x1
0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21871970
What about this:
"0x1"
0
 
LVL 13

Accepted Solution

by:
josgood earned 0 total points
ID: 21871992
Actually, I just figured it out.

Silly me (silly us) we were thinking that there would be an 'H' or an 'X' in the string.  Little do we know!  Urgh.

From http://msdn.microsoft.com/en-us/library/system.globalization.numberstyles(VS.80).aspx
"Indicates that the numeric string represents a hexadecimal value. Valid hexadecimal values include the numeric digits 0-9 and the hexadecimal digits A-F and a-f. Hexadecimal values can be left-padded with zeros. Strings parsed using this style are not permitted to be prefixed with "0x". "

I was thinking that the leading zero was disallowed.  The leading 'X' is also disallowed.

That is *really* surprising.

If the user is astonished, which I am, then the design is bad.

Thank you guys.  I appreciate you trying.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question