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?
Forums
toInt32
3 posts
• Page 1 of 1
Re: toInt32
Not sure what's going on there. Maybe it has something to do with explicitly implemented interfaces? http://msdn.microsoft.com/en-us/library ... int32.aspx (scroll down to the methods).
Regardless, you can use this instead I believe:
edit:
This will work too if you are sure the string is a number:
Regardless, you can use this instead I believe:
num = Convert.toInt32("123")
edit:
This will work too if you are sure the string is a number:
num = int.parse("123")
- nerdzero
- Posts: 286
- Location: Chicago, IL
Re: toInt32
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.
Thx.
Anyway .Net presents Convert.ToInt32 Method (Object, IFormatProvider) as well... so i agree it could an implementation issue.
Thx.
- relez
- Posts: 69
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 29 guests