C# int.Parse 方法
使用 C# 中的 int.Parse 方法,将数字的字符串表示形式转换为整数。如果无法转换字符串,则 int.Parse 方法将返回异常
假设你有一个数字的字符串表示形式。
string myStr = "200";
现在,要将它转换为整数,请使用 int.Parse()。它将转换。
int.Parse(myStr);
示例
using System.IO;
using System;
class Program {
static void Main() {
int res;
string myStr = "200";
res = int.Parse(myStr);
Console.WriteLine("String is a numeric representation: "+res);
}
}输出
String is a numeric representation: 200
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP