General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".


Postby relez » Thu Sep 26, 2013 12:42 pm

Just another question:

in C# ToInt32 accept string as argument. But if i try:

num = int.toInt32("123")

i get:

error: Argument 1 of method "toInt32" expects type IFormatProvider?, but the call is supplying type String.

What am i missing?
Posts: 69

Re: toInt32

Postby nerdzero » Thu Sep 26, 2013 1:48 pm

Not sure what's going on there. Maybe it has something to do with explicitly implemented interfaces? ... int32.aspx (scroll down to the methods).

Regardless, you can use this instead I believe:
num = Convert.toInt32("123")

This will work too if you are sure the string is a number:
num = int.parse("123")
Posts: 286
Location: Chicago, IL

Re: toInt32

Postby relez » Thu Sep 26, 2013 2:23 pm

Yep, int.parse works fine and it was my first choice.... i was just curious about toInt32....
Anyway .Net presents Convert.ToInt32 Method (Object, IFormatProvider) as well... so i agree it could an implementation issue.
Posts: 69

Return to Discussion

Who is online

Users browsing this forum: No registered users and 9 guests