C#输入的类型转换
来源:互联网 发布:淘宝卖家直播申请入口 编辑:程序博客网 时间:2024/05/22 04:38
using System;using System.Collections.Generic;using System.Text;namespace ConsoleIO{ class Program { static void Main(string[] args) { Console.Write("Please enter the first number: "); string strFirst = Console.ReadLine(); Console.Write("\nPlease enter the second number: "); String strSecond = Console.ReadLine(); //Int32.Parse(strFirst) int iFirst = Convert.ToInt32(strFirst); //Int32.Parse(strSecond) int iSecond = Convert.ToInt32(strSecond); int iResult = iFirst - iSecond; Console.WriteLine("the result is : " + iResult); Console.ReadLine(); } }}