Jump to content
  • Advertisement
Sign in to follow this  
Satan666

[.net] system:string to int

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm getting a input from a textbox, and what it'll be used for is as an integer, but I can't figure out how to convert it from a system::string __gc to and int. any ideas? [Edited by - Satan666 on July 26, 2005 4:37:15 AM]

Share this post


Link to post
Share on other sites
Advertisement
These functions throw when the argument is badly formatted. This is probably fine in your case. But just so that you know, .NET 2.0 has an additionnal function System::Int32::TryParse that returns a bool indicating success/failure.

Share this post


Link to post
Share on other sites
string s = "3213";
int iNum = int.Parse(s);
Be sure to catch the following exceptions (taken directly from MSDN):
System.ArgumentNullException: s is null.
System.ArgumentException: style is not a valid combination of System.Globalization.Numberstyles enumerated constants.
System.FormatException: s is not in a format compliant with style.
System.OverflowException: s represents a number less than System.Int32.MinValue or greater than System.Int32.MaxValue.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!