使用TryParse()来执行数值转换-LMLPHP

        static void Main()
{
var ageText = "25";
if (int.TryParse(ageText,out int age))
{
Console.WriteLine("Hi,My age is {0}",age);
}
else
{
Console.WriteLine("age {0} is not valid",ageText);
}
Console.ReadKey();
}

  

05-16 12:23