?
Solved

AllowHexSpecifier doesn't parse "x1"

Posted on 2008-06-25
3
Medium Priority
?
1,084 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 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