สมมติว่าสตริงของเราคือ −
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);
}
}