Try using the code below.
using System;
public class StringParsing
{
public static void Main()
{
TryToParse(rightAngleTB.Text);
}
private static void TryToParse(string value)
{
int number;
bool result = Int32.TryParse(value, out number);
if (result)
{
Console.WriteLine("Converted '{0}' to {1}.", value, number);
}
else
{
if (value == null) value = "";
Console.WriteLine("Attempted conversion of '{0}' failed.", value);
}
}
user1108948
source
share