string numString = "42"; int numInt = Int32.Parse(numString);
string numString = "not a number"; int numInt; bool isNumeric = Int32.TryParse(numString, out numInt); if (isNumeric) { Console.WriteLine(numInt); } else { Console.WriteLine("Conversion failed"); }This example demonstrates how to handle errors during the conversion process. The `Int32.TryParse` method attempts to convert the string "not a number" to an integer. If the conversion is successful, the resulting integer is printed to the console. If the conversion fails, an error message is printed instead. The `System.String.ToInt32` method is part of the `mscorlib` assembly, which is included in the .NET Framework.