在 C# 中將字串轉換為整數的方法
假設我們的字串為 -
string str ="9999";
現在,使用 Int32.Parse() 將字串轉換為整數 -
int n = Int32.Parse(str);
現在顯示整數值,如下面的程式碼所示 -
示例
using System; class Demo { static void Main() { string str ="9999"; int n = Int32.Parse(str); Console.WriteLine(n); } }
廣告