Convert.ToInt32字符串转为整型

来源:互联网 发布:网络侦探 dlc在哪里 编辑:程序博客网 时间:2024/05/30 04:27
using System;namespace ConsoleApplication2{    class Program    {        static void Main(string[] args)        {            Console.WriteLine("请输入第一个数字:");            string firstNO = Console.ReadLine();            int firstNOInt = Convert.ToInt32(firstNO);            Console.WriteLine("请输入第二个数字:");            string secondNO = Console.ReadLine();            int secondNOInt = Convert.ToInt32(secondNO);            Console.WriteLine("{0} + {1} = {2}" , firstNOInt, secondNOInt, firstNOInt + secondNOInt);            Console.ReadKey();        }    }}


原创粉丝点击