主要使用了Int32.Parse(),代码如下:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace InputIntFromConsole
 7 {
 8     class Program
 9     {
10         static void Main(string[] args)
11         {
12             string inputNumber;
13             int num;
14 
15             inputNumber = Console.ReadLine();
16 
17             num = Int32.Parse(inputNumber);
18 
19             //注意:这里可以使用+连接字符串和数字
20 string str = "What you input is: " + num;
21 
22             Console.WriteLine("What you input is: " + num);
23         }
24     }
25 }
 posted on 2012-10-22 13:24  Jiang, X.  阅读(9737)  评论(0编辑  收藏  举报