在 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);
}
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP