Convert BinaryString into int?

K

Keith

Hello,

I have some binarystrings in the registry (from an older j++ app) that I
need to convert at runtime to ints. What is the best practice for this? In
J++ you could just call Integer.ParseInt(val, 2); I've tried
Convert.ToUInt32(object, int) but I can't get the compiler to believe that
is a valid overload; it keeps complaining that it can't convert an int to an
IFormatProvider, which is a different overload.

Is that convert function broken? Is there another way to do this or am I
just screwed?

Keith
 
J

Jon Skeet

I have some binarystrings in the registry (from an older j++ app) that I
need to convert at runtime to ints. What is the best practice for this? In
J++ you could just call Integer.ParseInt(val, 2); I've tried
Convert.ToUInt32(object, int) but I can't get the compiler to believe that
is a valid overload; it keeps complaining that it can't convert an int to an
IFormatProvider, which is a different overload.

Is that convert function broken? Is there another way to do this or am I
just screwed?

There isn't a method Convert.ToUInt32(object, int). There's
Convert.ToUInt32(string, int) however - perhaps you just need to cast val to
a string first?
 
K

Keith

There isn't a method Convert.ToUInt32(object, int). There's
Convert.ToUInt32(string, int) however - perhaps you just need to cast val
to
a string first?

Apparently I can't read parameter lists, or at least not yesterday. Yes,
this works fine if cast. Thanks for the boot to the head ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top