从字符串转换

基本类型 / 数字 / 整型

using System;

var strNumber = "42";
var number = int.Parse(strNumber);

Console.WriteLine(number);