创建一个c#程序,实现字符串类型转整数类型

首先,创建一个c#程序

在代码编辑器中编写代码,点击Run按钮或者按下F5键来运行程序。

下面,编写将字符串类型转换为整数类型的代码。

复制代码
sing System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;




  namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            //例一:将字符串转换为布尔类型
            //string isTrue = "true";
            // bool a = bool.Parse(isTrue);
            //Console.WriteLine(isTrue);
            //Console.ReadKey();
            //例二:将字符串类型转换为int类型
            string a = "12345";
            int b = int.Parse(a);
            Console.WriteLine(b);


        }
    }
}
相关推荐
Empty_7771 小时前
编程之python基础
开发语言·python
疯狂吧小飞牛2 小时前
Lua 中的 __index、__newindex、rawget 与 rawset 介绍
开发语言·junit·lua
寻星探路4 小时前
Java EE初阶启程记13---JUC(java.util.concurrent) 的常见类
java·开发语言·java-ee
哲Zheᗜe༘4 小时前
了解学习Python编程之python基础
开发语言·python·学习
落日漫游5 小时前
数据结构笔试核心考点
java·开发语言·算法
寻找华年的锦瑟5 小时前
Qt-配置文件(INI/JSON/XML)
开发语言·qt
HY小海5 小时前
【C++】AVL树实现
开发语言·数据结构·c++
workflower6 小时前
Fundamentals of Architectural Styles and patterns
开发语言·算法·django·bug·结对编程
Roc-xb6 小时前
ModuleNotFoundError: No module named ‘conda_token‘
开发语言·python·conda
人工干智能6 小时前
Python 开发中:`.ipynb`(Jupyter Notebook 文件)和 `.py`(Python 脚本文件)
开发语言·python·jupyter