473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HexNumber Issues

Hi,

Would anyone be able to explain why I get a "Input string was not in a
correct format" on the following bit of code in C#??

public static int GENERIC_READ =
int.Parse("0xH80000000",System.Globalization.Numbe rStyles.HexNumber,
null);

Thanks

Dave Court

Nov 13 '06 #1
3 1514
Hi,
>
Would anyone be able to explain why I get a "Input string was not in a
correct format" on the following bit of code in C#??

public static int GENERIC_READ =
int.Parse("0xH80000000",System.Globalization.Numbe rStyles.HexNumber,
null);

Thanks

Dave Court
You don't want the "0xH" prefix there, you already specify that it's a
hexnumber.

And why not use:
public static uint GENERIC_READ = 0x80000000;

(note: the compiler requires a Uint here)
Hans Kesting
Nov 13 '06 #2
Thanks Hans

Really appreciate your help

Regards

Nov 13 '06 #3
Hi Dave,

Because the documentation says, "Strings parsed with this style are not
permitted to be prefixed with 0x".
[System.Globalization.NumberStyles.AllowHexSpecifie r]

HexNumber incorporates the AllowHexSpecifier flag in its value.

The code works if you remove the "0xH" prefix.

Hans mentioned in his response that the number is greater than what fits in a
signed Int32. The Parse method won't throw an exception but you might not get
the value you expect. Try uint and uint.Parse instead if that causes a
problem for you.

--
Dave Sexton

"bungle" <bu****@wizardbuy.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi,

Would anyone be able to explain why I get a "Input string was not in a
correct format" on the following bit of code in C#??

public static int GENERIC_READ =
int.Parse("0xH80000000",System.Globalization.Numbe rStyles.HexNumber,
null);

Thanks

Dave Court

Nov 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Loredo | last post by:
Hi folks- I'm about to move from a Solaris 8/SPARC environment to a Dell running RedHat 9. Are there any issues I need to be aware of in bringing my Python code over (mostly scientific...
28
by: grahamd | last post by:
Who are the appropriate people to report security problems to in respect of a module included with the Python distribution? I don't feel it appropriate to be reporting it on general mailing lists.
5
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
2
by: malcolm | last post by:
Hello, We have a robust (.NET 1.1 c# winforms) client-server application that utilizes many typed DataSets, typed DataTables and typed DataRows. Our application is a series of windows and popup...
1
by: Aliandro | last post by:
Hi Does any one know where I can find information regarding any issues with SQL and IIS being run under windows XP SP2? as I am in the process of programmning in Dot net and neet some way of...
5
by: Greg Wilkerson | last post by:
Ok, Someone tell me what I'm doing wrong. The statement below is returning 527.0 in v, instead of the expected 215. Am I missing something? double v; if (Double.TryParse("0d7",...
1
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there...
3
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.