代码: using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.Write("HELLO "); //输出不换行 Console.WriteLine("WORLD!"); //输出换行 Console.WriteLine("My \n Name \n Is \n C#!"); //转义字符 Console.WriteLine("{0}\n{1}", "Str0", "Str1"); //格式化文本 } } } 结果:
2,基本输入
代码: using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int number1; int number2; int sum; Console.WriteLine("Enter First Integer:"); number1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Second Integer:"); number2 = Convert.ToInt32(Console.ReadLine()); sum = number1 + number2; Console.WriteLine("Sum is {0}", sum); } } } 结果: