[.net] system:string to int
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]
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement